分享一个通过ip获取省市的接口

今天看到一个通过ip获取省市区的接口不过分享给大家!

ip地址:http://ip.taobao.com/service/getIpInfo.php?ip='.$ip

使用方法:

<?php

$url ='http://ip.taobao.com/service/getIpInfo.php?ip=' ;

$ip = '124.202.230.166';

$path = $url . $ip;

$res = file_get_contents($path);

var_dump($res);

结果:

{"code":0,"data":{"ip":"124.202.230.166","country":"中国","area":"","region":"北京","city":"北京","county":"XX","isp":"鹏博士","country_id":"CN","area_id":"","region_id":"110000","city_id":"110100","county_id":"xx","isp_id":"1000143"}}

6dc7db2281106557479740eed70f9517.png

国家 省市 邮编等等等出来了!是不是! 收藏下,方便以后遇到用ip的地方!
原文:https://www.liangjucai.com/article/175

展开阅读全文

没有更多推荐了,返回首页