【发布时间】:2012-02-20 18:34:59
【问题描述】:
我关注了这个网站 How do I retrieve the visitor's ISP through PHP? 获取 ISP 数据,但它不再工作(未能打开流:HTTP 请求失败)。我也尝试过使用生硬
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://www.whatismyipaddress.com/ip/132.123.23.23');
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") );
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
echo $query;
但我收到以下错误:
Moved Permanently
The document has moved here.
有人知道类似的解决方案吗?
已编辑
curl 解决方案仅适用于我的本地主机,不幸的是,网络主机服务不允许这样做。有人知道使用 file_get_contents 的解决方案吗?
【问题讨论】:
-
不就是301重定向到非www版本吗?另请注意,这违反了TOS。
标签: php