Php 在路上,爸爸贝宝没有得到任何回应
您好,我在PHP中实现了paypal express checkout API,在我的本地主机上它成功运行,但在Go daddy托管服务器上它不会显示任何内容,它只显示一个空白页面,它甚至不会在paypal页面上运行,也不会显示任何错误消息。我猜可能是curl请求或https响应是问题所在 这是我的要求Php 在路上,爸爸贝宝没有得到任何回应,php,curl,paypal,paypal-ipn,Php,Curl,Paypal,Paypal Ipn,您好,我在PHP中实现了paypal express checkout API,在我的本地主机上它成功运行,但在Go daddy托管服务器上它不会显示任何内容,它只显示一个空白页面,它甚至不会在paypal页面上运行,也不会显示任何错误消息。我猜可能是curl请求或https响应是问题所在 这是我的要求 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $API_Endpoint); curl_setopt($ch,
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API operation, version, and API signature in the request.
$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";
// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
// Get response from the server.
$httpResponse = curl_exec($ch);
if(!$httpResponse) {
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}
// Extract the response details.
$httpResponseAr = explode("&", $httpResponse);
$httpParsedResponseAr = array();
foreach ($httpResponseAr as $i => $value) {
$tmpAr = explode("=", $value);
if(sizeof($tmpAr) > 1) {
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
}
}
if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
}
return $httpParsedResponseAr;
更多参考,这是代码i
我确信curl请求或https响应中存在一些问题,请尽快指导我。将此放在脚本的顶部
error_reporting(E_ALL);
ini_set('display_errors', '1');
这将允许您看到正在发生的PHP错误
您可能还想更改此
if(!$httpResponse) {
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}
到
按照您的方式,如果有任何内容返回到$httpResponse,它将被视为是真的。但是,如果确实发生curl错误,在那里检查curl错误将始终输出错误消息和编号 为了将来的参考,你可能想看看我的。它使任何API调用你想与贝宝非常快速和容易。嗨安德鲁谢谢你,但仍然是相同的问题没有发生。从Localhost来看,它正在工作,我想go daddy服务器缺少了一些东西。一个空白的PHP页面通常意味着发生了PHP错误,但没有显示错误。我给你的第一个片段应该覆盖它。如果不是这样,您必须使用其他类似htaccess或php.ini的工具,以某种方式永久禁用错误。在任何情况下,如果您查看原始web服务器日志,您都应该能够看到PHP错误。嘿,非常感谢,它成功了,很抱歉回复太晚
if($curl_error($ch)) {
exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}