通过新浪接口根据IP获得来源城市
2018-03-07 15:05
471 查看
function getIpLookup($ip = ''){ if(empty($ip)){ return false; } $res = @file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' . $ip); if (empty($res)) { return false; } $jsonMatches = array(); preg_match('#\{.+?\}#', $res, $jsonMatches); if (!isset($jsonMatches[0])) { return false; } $json = json_decode($jsonMatches[0], true); if (isset($json['ret']) && $json['ret'] == 1) { $json['ip'] = $ip; unset($json['ret']); } else { return false; } return $json; }结果:
Array ( [start] => -1 [end] => -1 [country] => 中国 [province] => 上海 [city] => 上海 [district] => [isp] => [type] => [desc] => [ip] => 101.231.183.230 )
相关文章推荐
- 通过新浪接口当前IP地址所在城市
- 根据IP地址获取所在城市【通过新浪接口】
- 根据IP地址获取所在城市【通过新浪接口】
- 通过新浪IP服务器获得的当前客户端IP地址对应的国家、省份或直辖市、城市信息
- 想在自己的android应用中获得当天的天气情况,这该怎么做呢?不用担心。中国国家气象局提供了获取所在城市天气预报信息接口。通过这个接口,我们就可以获取天气信息了。
- asp.net根据ip获得城市地址
- php-根据用户IP获得用户地址-新浪
- 通过cxf发布的webservice接口中获取来源地址的IP
- 使用新浪的接口获取用户当前IP的位置地点身份城市地区
- 通过请求接口的办法获得本设备IP以及IP地址
- PHP利用新浪IP接口,来实现IP地址定位具体城市
- 调用新浪接口,获取电脑ip,所在省份城市
- PHP通过访问第三方接口,根据IP地址获取所在城市
- 根据IP获得城市信息(百度API的运用)
- 新浪接口之PHP根据IP地址获取所在城市
- 通过新浪接口获取IP地理位置
- 根据ip获得国家,省,城市,运营商
- PHP获取ip与ip所在城市 (新浪接口)
- 前端通过获取广域网ip然后根据ip得到所在的城市