您好我使用CURL获取网址内容,但我不知道为什么会失败
使用var_dump($stat);
时,我的卷曲代码的结果是:bool(false)
但我用浏览器测试了网址,而且evry的东西还可以,我有真正的版画:结果是user is offline
http://mysite:13060/getshot/1
这是我的CURL代码可以告诉我什么问题?
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$stat = get_data('http://mysite:13060/getshot/1');
var_dump($stat);