gpt4 book ai didi

php - 如何调试需要基本身份验证但根本没有响应的 php nusoap 调用?

转载 作者:可可西里 更新时间:2023-11-01 00:08:45 25 4
gpt4 key购买 nike

我正在尝试重写一个 Drupal 模块,该模块已经落后于它连接到的网关的 API。

我认为导致问题的代码的精简版本如下:

$namespace = ($this->testing) ? 'https://api.sandbox.ewaypayments.com/' : 'https://api.ewaypayments.com/';
$endpoint = $this->url;
$httpUsername = $this->user_name;
$httpPassword = $this->password;

$client = new nusoap_client($endpoint, TRUE);
$client->setCredentials($httpUsername, $httpPassword, 'basic');
$client->response_timeout = 50;
$result = $client->call($operation, array('request' => $params), $namespace);

$result 始终为假。如果我将这样的东西放入我的代码中,它也会始终返回 empty:

$error = $client->getError(); 
watchdog('connection_message', $error);

我有点不知所云,在我的 Apache 日志或 Drupal 看门狗中没有任何错误消息,我看不到前进的方向。

最佳答案

<强>1。打开 PHP 错误报告(如果尚未打开)。

检查 php.ini 文件中的 error_reportingdisplay_errors 设置是否设置为 E_ALLOn 当你在本地开发时。您还可以在 PHP 脚本的开头添加这些指令以在运行时设置它们:

error_reporting(E_ALL);
ini_set('display_errors', 'On');

<强>2。像这样捕获 NuSOAP 错误:

$result = $client->call($operation, array('request' => $params), $namespace);
if ($client->fault) {
echo 'Error: ';
print_r($result);
} else {
// check result
$err_msg = $client->getError();
if ($err_msg) {
// Print error msg
echo 'Error: '.$err_msg;
} else {
// Print result
echo 'Result: ';
print_r($result);
}
}

<强>3。验证您使用的 API 参数和端点是否正确:

来自eWAY API reference ,您的端点是:

https://api.ewaypayments.com/soap.asmx (production)
https://api.sandbox.ewaypayments.com/soap.asmx (sandbox)

<强>4。您可以进行逆向工程的类似 eWAY API 项目:

关于php - 如何调试需要基本身份验证但根本没有响应的 php nusoap 调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29979971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com