我試圖使用捲曲與服務器的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。
謝謝。
不響應的服務器檢查curl_error的值() –