0
我有一個錯誤捲曲代碼301.我得到一個錯誤301當我提出請求curl leboncoin.fr 我嘗試通過添加curl_setopt($ ch,CURLOPT_FOLLOWLOCATION,1)在我的函數curl的代碼中。代碼工作僅在一天內找到。而第二天,我又發現了同樣的代碼erreor(301錯誤)錯誤301通過在url上使用函數fileget_contents_curl
這裏是下面的捲曲代碼:
function file_get_contents_curl($url)
{
$ch = curl_init();
$timeout = 10;
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
**curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);**
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);
curl_setopt($ch, CURLOPT_FORBID_REUSE , 1);
curl_setopt($ch, CURLOPT_TIMEOUT , 10);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
你有任何想法解決這個? 謝謝。
檢查獲取響應需要多長時間。 – PatomaS