分享一个通过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的地方!
原文地址:梁巨才博客

一个新手站长 has written 6 articles

该作者很低调,还没有自我介绍~

积分:172 等级:P3 职业:未设置 城市:未设置

0 条回复

登录后才能进行评论,立即登录?