In a recent project, a certain module needs to obtain regional location and operator information based on the IP address. Previously, it was based on a free access to this information provided by Taobao.
http://ip.taobao.com/service/getIpInfo.php?ip=112.10.111.18
The return result is
{
"msg": "Server is busy ,Current qps =8000.0",
"code": 3
}
Damn it, is it so weird? Does this free interface that have been used all the time have to be charged? I can't help but check Taobao IP address database http://ip.taobao.com/ to see if it is still available http://ip.taobao.com/ipSearch?ipAddr=112.10.111.18
! ! ! ! ! It can be queried! ! !
Continue to research and found that the open path has been modified, and the accessKey parameter has been added. Let’s take a look at the Rest API documentation.
// 淘宝IP地址库Rest API文档
1. 请求接口(GET,POST):
/outGetIpInfo?ip=[ip地址字串]&accessKey=[访问密匙]
2. 响应信息:
(json格式的)国家 、省(自治区或直辖市)、市(县)、运营商
3. 返回数据格式:
{"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":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}}
其中code的值的含义为,0:成功,1:服务器异常,2:请求参数异常,3:服务器繁忙,4:个人qps超出。
Is it suddenly clear here, right! The suspicion is right, the interface address has been modified, but there is no charge! (Services that do not charge are good services! Hahaha!)
新的地址为:http://ip.taobao.com/outGetIpInfo?ip=[ip]&accessKey=[访问密匙]
http://ip.taobao.com/outGetIpInfo?ip=112.10.111.18&accessKey=
{
"data": {
"area": "",
"country": "中国",
"isp_id": "100025",
"queryIp": "112.10.111.18",
"city": "杭州",
"ip": "112.10.111.18",
"isp": "移动",
"county": "",
"region_id": "330000",
"area_id": "",
"county_id": null,
"region": "浙江",
"country_id": "CN",
"city_id": "330100"
},
"msg": "query success",
"code": 0
}
OK! Get it done!
-------------------------------------------------- ----------------------
author: World coding
source: CSDN
original: https://blog.csdn.net/dgxin_605/article/details/107131724
copyright notice : This article is the original article of the blogger, please attach a link to the blog post if you reprint it!
------------------------------------------------------------------------