发布网友 发布时间:2022-04-23 07:01
共1个回答
热心网友 时间:2022-06-17 04:21
function GetIpLookup($ip = ''){
$res = @file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' . $ip);
if(empty($res)){ return false; }
$jsonMatches = array();
preg_match('#\{.+?\}#', $res, $jsonMatches);
if(!isset($jsonMatches[0])){ return false; }
$json = json_decode($jsonMatches[0], true);
if(isset($json['ret']) && $json['ret'] == 1){
$json['ip'] = $ip;
unset($json['ret']);
}else{
return false;
}
return $json;
}
$ipInfos = $this->GetIpLookup('222.223.191.12'); //.com IP地址
var_mp($ipInfos);