dsbfbz75185
2012-05-03 11:56
浏览 90
已采纳

Paypal - 新服务器中的CURL响应为0(连接超时),在旧服务器中没问题

I'm trying to connect to Paypal Sandbox from a new server. If I test the code in my local computer (using XAMPP) it works fine. Also, if I test the code in my old server, it works ok too (same PHP version and libraries, and the new server should have the same configuration as the old (although I'm starting to doubt it...).

I redirect the CURL output to a file and this is what I get (similar output in curl_error()):

About to connect() to svcs.sandbox.paypal.com port 443 (#0)
Trying 173.0.82.89... * Connection timed out
couldn't connect to host
Closing connection #0

This is the output of curl_getinfo():

[url] => https://svcs.sandbox.paypal.com/AdaptivePayments/Pay?actionType=PAY...
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0.058702
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0

This is the PHP code:

$ch = curl_init();    
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER
    , array(
    'X-PAYPAL-SECURITY-USERID: '.$api_userid
    , 'X-PAYPAL-SECURITY-PASSWORD: '.$api_pass
    , 'X-PAYPAL-SECURITY-SIGNATURE: '.$api_signature
    , 'X-PAYPAL-APPLICATION-ID: '.$api_appid
    , 'X-PAYPAL-REQUEST-DATA-FORMAT: NV'
    , 'X-PAYPAL-RESPONSE-DATA-FORMAT: NV'
    )    
);

$response = curl_exec($ch);

I think the problem points to a server configuration issue, but I'm a little lost in wich way I have to look: PHP configuration, Apache, firewall, ... ¿any ideas?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doujiao3016 2012-05-03 21:05
    已采纳

    OK. It was a SSL configuration problem. The outgoing SSL port (443) was closed so the server couldn't establish a connection with Paypal.

    Thanks for your ideas :)

    评论
    解决 无用
    打赏 举报
  • 查看更多回答(1条)

相关推荐 更多相似问题