latest v2022.12.01.1812

常用接口

No. 接口地址 提供商 状态
1 https://pv.sohu.com/cityjson?ie=utf-8 搜狐 正常
2 https://apis.map.qq.com/ws/location/v1/ip?output=json&key=KUQBZ-FYDCU-YMVVN-2DDW5-7WDYE-5JBJR&ip=1.2.4.8 腾讯地图 正常
3 https://lbs.amap.com/api/webservice/guide/api/ipconfig 高德地图 正常
4 https://whois.pconline.com.cn/ipJson.jsp?ip=1.2.3.4&json=true 太平洋 正常
5 https://ipapi.co/112.65.48.150/json/ IPAPI 正常
6 https://api.ip.sb/geoip IPSB 正常
7 https://ipinfo.io/developers ipinfo.io 正常
8 https://dev.maxmind.com/minfraud/api-documentation MaxMind 正常
9 https://ipstack.com/documentation ipstack 正常
10 https://ipapi.com/documentation ipapi™ 正常
11 https://www.ip2location.com/web-service/ip2location IP2Location™ 正常
12 https://www.ip2location.com/web-service/ip2proxy IP2Proxy™ 正常
13 https://geo.ipify.org/docs IPIFY 正常
14 https://ipgeolocation.io/ip-location/1.2.4.8 ipgeolocation 正常
15 https://db-ip.com/api/basic/ DBIP 正常
16 http://ip-api.com/json/114.114.114.114?lang=zh-CN IP-API 正常
0 http://ip.taobao.com/service/getIpInfo.php?ip=8.8.8.8 淘宝 停用
0 https://ip.huomao.com/ip?ip=8.8.8.8 火猫 停用
0 https://ip.ws.126.net/ipquery?ip=223.6.6.6 网易 停用

注意:以上可能部分平台需要注册获取 KEY 或付费,具体请查阅发开文档和使用条款。

接口套嵌

<?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 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用*标注