【问题标题】:On go daddy paypal is not getting any response在去爸爸贝宝没有得到任何回应
【发布时间】: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


【解决方案1】:

把它放在脚本的顶部。

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

这将让您看到正在发生的 PHP 错误。

您可能还想更改此设置...

if(!$httpResponse) {
            exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
        }

到...

    if($curl_error($ch)) { 
        exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
}

按照您的方式,如果有任何东西被带回 $httpResponse ,它将被视为真实。但是,如果确实发生 curl 错误,则在那里检查 curl 错误将始终输出错误消息和编号。

【讨论】:

  • 嗨,安德鲁,谢谢你,但同样的问题没有发生。从 Localhost 它正在工作,我猜 go daddy 服务器缺少一些东西。
  • 一个空白的 PHP 页面通常意味着发生了一个 PHP 错误但没有显示错误。我给你的第一个 sn-p 应该覆盖它。如果不是,您必须以某种方式永久禁用诸如 htaccess 或 php.ini 之类的错误。无论如何,如果您查看原始 Web 服务器日志,您应该能够看到 PHP 错误。
  • 嘿,非常感谢,成功了,抱歉回复晚了
猜你喜欢
  • 2018-08-04
  • 1970-01-01
  • 1970-01-01
  • 2018-08-17
  • 2016-07-05
  • 1970-01-01
  • 2013-11-18
  • 1970-01-01
  • 2013-02-12
相关资源
最近更新 更多