2011-07-21 55 views
0

我試圖使用捲曲與服務器的API進行通信:什麼是這些PHP curl響應標題指示?

$ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, 'pilot-payflowpro.paypal.com'); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); 
    curl_setopt($ch, CURLOPT_HEADER, 1); // tells curl to include headers in response 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable 
    curl_setopt($ch, CURLOPT_TIMEOUT, 45); // times out after 45 secs 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // this line makes it work under https 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $plist); //adding POST data 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); //verifies ssl certificate 
    curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE); //forces closure of connection when done 
    curl_setopt($ch, CURLOPT_POST, 1); //data sent as POST 

    $result = curl_exec($ch); 
    $headers = curl_getinfo($ch); 
    print_r($headers); 

然而,$ result變量是空的,這是returntransfer設置爲1,意味着沒有響應給出。打印標題給出:

([url] => HTTP://pilot-payflowpro.paypal.com [content_type] => [http_code] => 0 
[header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 
[redirect_count] => 0 [total_time] => 1.656 [namelookup_time] => 0.062 [connect_time] => 0 
[pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 
[speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 
[starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array ()) 

這在調試方面有何建議?我在啓用curl的本地桌面上使用了wamp。

謝謝。

+0

不響應的服務器檢查curl_error的值() –

回答

1

好像你CURLOPT_URL參數是錯誤的...一個完全充滿URL(http://pilot-payflowpro.paypal.com)

在你的榜樣,嫋嫋不知道嘗試哪些協議使用(HTTP,HTTPS)

編輯:用https://pilot-payflowpro.paypal.com嘗試它,因爲你提到的http協議

+0

現在試了一下 - 沒有什麼區別。仍然是一個空的迴應,並且仍然與上面相同。 – David

+0

當我在瀏覽器中測試'http:// pilot-payflowpro.paypal.com'時,我有相同的超時時間。我認爲正確的URL是'https:// pilot-payflowpro.paypal.com'(安全)。試試CURLOPT_URL –

+0

謝謝。這解決了我的問題,並收到了API的回覆。 – David