curl_init无法正常工作

时间:2012-08-30 11:40:52

标签: php curl

我正在使用基于cURL的以下功能

$url = "http://www.web_site.com";
$string = @file_get_contents($url);
if(!$string){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$string = curl_exec($ch);
curl_close($ch);
}

但是由于这个功能突然我的网站停止了,一旦我删除curl它工作正常 所以我认为我的主机禁用它所以我检查出来

Click here to check it out

它应该正常工作,这有什么不对?

Image

〜任何帮助,我要对我的托管服务提供商说什么!!

1 个答案:

答案 0 :(得分:0)

file_get_contents方法不会查看网址标题,请尝试使用启用了CURLOPT_FOLLOWLOCATION的{​​cURL}和CURLOPT_MAXREDIRS所使用的值。

相关问题