admin 发表于 2023-7-4 22:58:32

高德地图定位城市

public static function ip()
{
$ip=Request::ip(); //thinkphp获取ip
    $type='json';//数据返回方式xml    json
    $key='你的key';//高德地图web服务key
//(https://lbs.amap.com/api/ios-track/summary/)
    $url='https://restapi.amap.com/v3/ip?ip='.$ip.'&output='.$type.'&key='.$key;
    $result = file_get_contents($url);
    $result = json_decode($result,true);
    return $result['province'].$result['city'];
}

页: [1]
查看完整版本: 高德地图定位城市