发布于 5年前

PHP 调用淘宝 IP 地址解析获取对应的地理位置信息

$data =  json_decode(file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip=202.106.0.20'));
echo "<pre>";
print_r($data);

会输出:

stdClass Object
(
    [code] => 0
    [data] => stdClass Object
        (
            [country] => 中国
            [country_id] => 86
            [area] => 华北
            [area_id] => 100000
            [region] => 北京市
            [region_id] => 110000
            [city] => 北京市
            [city_id] => 110000
            [county] => 
            [county_id] => -1
            [isp] => 联通
            [isp_id] => 100026
            [ip] => 202.106.0.20
        )
)
©2020 edoou.com   京ICP备16001874号-3