Taobao announced their IP library http://ip.taobao.com/, as well as the rest API interface, but each user's access frequency should be less than 10QPS, access mode: http://ip.taobao.com/service/ Getipinfo.php?ip=[ip address string], returns the content in JSON format. With IP query, IP statistics and other functions. The number of IP owned by the major operators and other information. Next, let's take an example of getting IP:
Copy Code code as follows:
<?php
/**
* Get IP 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"));
?>