Taobao has announced their IP library http://ip.taobao.com/, as well as the REST API interface, but the access frequency of each user must be less than 10qps, and the access method is: http://ip.taobao.com/service /getIpInfo.php?ip=[ip address string], the returned content is in json format. It has functions such as IP query and IP statistics. Information such as the number of IPs owned by major operators. Next, let’s introduce an example of obtaining IP:
Copy code The code is as follows:
/* *
* Obtain IP geographical location through Taobao IP interface
* @param string $ip
* @return: string
**/
function getCity($ip)
{
$url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip;
$ipinfo=json_decode(file_get_contents($url));
if($ipinfo->code=='1'){
return false;
}
$city = $ipinfo ->data->region.$ipinfo->data->city;
return $city;
}
header("Content-Type:text/html;charset=utf-8 ");
var_dump(getCity("112.234.69.189"));
?>
http://www.bkjia.com/PHPjc/824921.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824921.htmlTechArticleTaobao announced their IP library http://ip.taobao.com/, as well as REST API interface, However, the access frequency of each user must be less than 10qps. Access method: http://ip.taobao.com/service/getIpInfo....