Home >Backend Development >PHP Tutorial >Taobao IP address database API interface (PHP) obtains address information through ip_PHP tutorial
Here we introduce the method of using Taobao IP address library API interface (PHP) to obtain address information through IP. We have introduced Sina before, and you can introduce Taobao here.
Taobao IP address library website: http://ip.taobao.com/
Services provided include:
1. Based on the IP address provided by the user, quickly query the geographic information and geographic-related information where the IP address is located, including country, province, city and operator.
2. Users can update our service content based on their location and IP address.
Interface description:
1. Request interface (GET method):
http://ip.taobao.com/service/getIpInfo.php?ip=[ip address string]
2. Response information (json format data):
Country, province (autonomous region or municipality), city (county), operator
3. Return data format:
The code is as follows | Copy code | ||||
{"code":0,"data":{"ip":"210.75.225.254","country":"u4e2du56fd","area":"u534eu5317",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000", |
4. PHP code example:
代码如下 | 复制代码 |
function getCity($ip) |
The code is as follows | Copy code |
function getCity($ip) {$url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip; |
elseif (getenv("HTTP_CLIENT_IP")){
http://www.bkjia.com/PHPjc/632722.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632722.htmlTechArticleHere we introduce the method of using Taobao IP address library API interface (PHP) to obtain address information through ip, which was introduced earlier Sina, you can introduce Taobao here. Taobao IP address database URL:...