【发布时间】:2015-03-28 06:54:17
【问题描述】:
您好,我在 PHP 中实现了 paypal express checkout API,在我的本地主机上它成功运行,但在 Go daddy 托管服务器上它不会显示任何内容,它只显示一个空白页面,它甚至不会进入 paypal 页面,也不会显示任何内容错误信息。我猜可能是 curl 请求或 https 响应的问题
这是我的 curl 请求。
$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;
更多参考代码是我integrated。
我确定 curl 请求或 https 响应有问题,请尽快指导我。
【问题讨论】:
-
为了将来的参考,你可能想看看我的PHP class library for PayPal。它使您想使用 PayPal 进行的任何 API 调用都变得非常快速和轻松。
标签: php curl paypal paypal-ipn