常用接口
接口地址 | 提供商 | 状态 |
https://pv.sohu.com/cityjson?ie=utf-8 | 搜狐 | 正常 |
https://ip.ws.126.net/ipquery?ip=223.6.6.6 | 网易 | 正常 |
http://ip-api.com/json/114.114.114.114?lang=zh-CN | IP-API | https 收费 |
https://whois.pconline.com.cn/ipJson.jsp?ip=1.2.3.4&json=true | 太平洋 | 正常 |
https://ipapi.co/112.65.48.150/json/ | IPAPI | 正常 |
https://api.ip.sb/geoip | IPSB | 正常 |
https://ipapi.com/documentation | IPAPICO | 正常 |
https://apis.map.qq.com/ws/location/v1/ip?output=json&key=KUQBZ-FYDCU-YMVVN-2DDW5-7WDYE-5JBJR&ip=1.2.4.8 | 腾讯地图 | 正常 |
https://geo.ipify.org/docs | IPIFY | 正常 |
https://ipgeolocation.io/ip-location/1.2.4.8 | ipgeolocation | 申请 KEY |
https://lbs.amap.com/api/webservice/guide/api/ipconfig | 高德地图 | 申请 KEY |
https://db-ip.com/api/basic/ | DBIP | 商用 |
http://ip.taobao.com/service/getIpInfo.php?ip=8.8.8.8 | 淘宝 | 停用 |
https://api.ttt.sh/ip/qqwry/ | 3T | 停用 |
https://ip.huomao.com/ip?ip=8.8.8.8 | 火猫 | 停用 |
接口套嵌
<?php
header('Content-type:application/json;charset=gb2312');
$ip = @file_get_contents("https://pv.sohu.com/cityjson?ip=".$_GET["ip"]);
echo $ip;
?>
调用示例
PHP
<?php //------ get ipapidata ------//
function get_code($url){
$curl = curl_init();
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_URL, $url);
$resp = curl_exec($curl);
curl_close($curl);
return $resp;
}
$resp = get_code("http://ip-api.com/json/?lang=zh-CN");
$resp = json_decode($resp,true);
$getCity = $resp[regionName];
echo $getCity;
?>
JSON
<span id="idTestJson"></span><br/>
<script>
function testJson(obj) {
document.getElementById("idTestJson").innerHTML = "省 ["+obj.pro+"] 市 ["+obj.city+"] 区 ["+obj.region+"]";
}
</script>
<script src="https://whois.pconline.com.cn/ipJson.jsp?callback=testJson&ip="></script>
JS
<span id="idJsShow"></span>
<script>
function jsShow(location){
document.getElementById("idJsShow").innerHTML = location;
}
</script>
<script src="https://whois.pconline.com.cn/jsFunction.jsp?callback=jsShow&ip="></script>
<script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
document.write(returnCitySN["cip"]+','+returnCitySN["cname"])
</script>
<script src="https://ip.ws.126.net/ipquery"></script>
<script type="text/javascript">
document.write(localAddress["province"]+','+localAddress["city"])
</script>
0 条评论