PHP Curl 請求接口時遇到下列錯誤!
{"error":"Operation timed out after 10001 milliseconds with 0 bytes received"}
{"error":"Empty reply from server"}
這兩個問題,第一個問題大概意思是請求時間過長造成的。
解決辦法:
// 超時設置
curl_setopt($curl, CURLOPT_TIMEOUT, 300);
設置更大的時間
然鵝,造成整個問題的原因是:
$header = array(
'Content-Type: application/json',
'Content-Length: ' . strlen(json_encode($post_data))
);
Content-Length 對就是這個參數,造成的假死和timeout
參考鏈接: https://www.jianshu.com/p/ea12be063b2e
文章來源:劉俊濤的博客 歡迎關注公眾號、留言、評論,一起學習。
__________________________________________________________________________________
若有幫助到您,歡迎點擊推薦,您的支持是對我堅持最好的肯定(*^_^*)