我跟着這個網站 How do I retrieve the visitor's ISP through PHP? 獲取ISP數據,但它不再工作(無法打開流:HTTP請求失敗)。我還試圖用生硬的我如何通過PHP檢索訪客的ISP
$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.
有誰知道類似的解決方案?
EDITED
捲曲解決方案是在我的本地唯一的工作,遺憾的是主網絡服務不允許。有人知道使用file_get_contents的解決方案嗎?
這不僅僅是301重定向到非www版本嗎?另請注意,這違反了[TOS](http://whatismyipaddress.com/terms-of-use)。 – cmbuckley 2012-02-20 18:37:51
啊,是的,它的工作 – 2012-02-20 18:39:53