复制代码代码如下:
function getIPLoc_sina($queryIP){
$url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php ?format=json&ip='.$queryIP;
$ch =curl_init($url);
curl_setopt($ch,CURLOPT_ENCODING ,'utf8');
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 取得データを返します
$location =curl_exec($ch);
$location = json_decode($location);
curl_close($ch);
$loc = "";
if($location===FALSE) 戻り値 "";
if (empty($location->desc)) {
$loc = $location->province.$location->city.$location->district.$location->isp;
}else{ $loc = $location->desc;
}
return $loc;
}
echo getIPLoc_sina("183.37.209.57");
?>
http://www.bkjia.com/PHPjc/718616.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/718616.html技術記事复制代码代码如下: ?php function getIPLoc_sina($queryIP){ $url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json $ch =curl_init($url); curl_setopt($ch,CURL...