public static function getUserCity($longitude, $latitude) { $url = "https://apis.map.qq.com/ws/geocoder/v1/?location=" . $latitude . ',' . $longitude . "&key=XXXXXXXXXXXX"; $res = CurlService::curlGet($url); $res['data'] = json_decode($res['data'], true); if ($res === false) { throw new \Exception('api请求失败', '3'); } if ($res['data']['status'] !== 0) { throw new \Exception($res['data']['message'], '3'); } $provinceName = $res['data']['result']['address_component']['province']; $cityName = $res['data']['result']['address_component']['city']; return ['province_name' => $provinceName, 'city_name' => $cityName]; }