One, about Taobao IP address library
The services we currently offer include:
1. According to the IP address provided by the user, the geographic and geographic information of the IP address is quickly queried, including the state, province, city and operator.
2. Users can update our service content according to their location and the IP address used.
Our Advantages:
1. Provide the country, province, city, county, operator omni-directional information, information dimension wide, format specification.
2. Provide a sound statistical analysis of the report, the provincial accuracy of more than 99.8%, the city accuracy of more than 96.8%, data quality is guaranteed.
Second, the interface description
1. Request interface (GET):
Http://ip.taobao.com/service/getipinfo.php?ip=[ip Address string]
2. Response Information:
(JSON-formatted) country, province (autonomous region or municipality), city (county), operator
3. Return Data format:
Copy Code code as follows:
{"Code": 0, "data": {"IP": "210.75.225.254", "Country": "\U4E2D\U56FD", "area": "\u534e\u5317",
"Region": "\u5317\u4eac\u5e02", "City": "\u5317\u4eac\u5e02", "County": "", "ISP": "\u7535\u4fe1",
"country_id": "The", "area_id": "100000", "region_id": "110000", "city_id": "110000",
"county_id": "1", "isp_id": "100017"}}
Where the value of the code means, 0: Success, 1: failure.
Note: In order to ensure the normal operation of the service, each user's access frequency should be less than 10QPS.
Third, the IP library contains data
1. IP number Statistics
2. IP accuracy, coverage statistics
Iv. IP Library What can be done?
1. Remind users not to log in frequently
2. Global statements
3. National statements
4. Make the national report according to the provider
5. Statistics providers by region
6. Other
Five, PHP call instance
Copy Code code as follows:
<?php
/**
* Get user Real IP
*/
function GetIP () {
Static $realip;
if (Isset ($_server)) {
if (Isset ($_server["http_x_forwarded_for"])) {
$realip = $_server["Http_x_forwarded_for"];
else if (Isset ($_server["HTTP_CLIENT_IP"])) {
$realip = $_server["Http_client_ip"];
} else {
$realip = $_server["REMOTE_ADDR"];
}
}else {
if (getenv ("Http_x_forwarded_for")) {
$realip = getenv ("Http_x_forwarded_for");
else if (getenv ("Http_client_ip")) {
$realip = getenv ("Http_client_ip");
} else {
$realip = getenv ("REMOTE_ADDR");
}
}
return $realip;
}
/**
* Get IP location
* Taobao IP interface
* @Return: Array
*/
function Getcity ($IP)
{
$url = "http://ip.taobao.com/service/getIpInfo.php?ip=". $ip;
$ip =json_decode (file_get_contents ($url));
if ((string) $ip->code== ' 1 ') {
return false;
}
$data = (array) $ip->data;
return $data;
}
Print_r (getcity (' 123.22.34.213 '));
?>
VI: C # invocation Instance
Copy Code code as follows:
Taobaoip RESULT1 = Taobaoiphelper.getip ("8.8.8.8");
if (Result1.code = 0)
{
Console.WriteLine (String. Format (the call succeeded. The IP country is {0}, the province is {1}, the city is {2}, the operator is {3} "
, Result1.data.country, Result1.data.region, result1.data.city, Result1.data.isp)
);
}
Else
{
Console.WriteLine ("Failure, Reason for:" +result1.errormsg);
}
taobaoip[] result2 = Taobaoiphelper.getdomain ("lixin.me");
foreach (Taobaoip item in RESULT2)
{
if (Item.code = 0)
{
Console.WriteLine (String. Format (the call succeeded. The IP country is {0}, the province is {1}, the city is {2}, the operator is {3} "
, Item.data.country, Item.data.region, item.data.city, Item.data.isp)
);
}
Else
{
Console.WriteLine ("Failure, Reason for:" + item.errormsg);
}
}