原本使用新浪Api,然后发现不行了,以下小编重新查找了几个,个人推荐太平洋的接口
1、首先获取真实ip
$ip = $_SERVER['REMOTE_ADDR'];
2、要知道的Api接口
几个接口
$ip 为上边声明变量
淘宝 : http://ip.taobao.com/service/getIpInfo.php?ip=$ip;
搜狐 : http://pv.sohu.com/cityjson?ie=utf-8;
太平洋 : http://whois.pconline.com.cn/ip.jsp?ip=$ip;
360 : http://ip.360.cn/IPQuery/ipquery?ip=$ip;
示例(淘宝接口)
{ "code":0, "data":{ "ip":"39.108.236.83", "country":"中国", "area":"", "region":"广东", "city":"深圳", "county":"XX", "isp":"阿里云", "country_id":"CN", "area_id":"", "region_id":"440000", "city_id":"440300", "county_id":"xx", "isp_id":"1000323" } }
其他用法可自行搜索