添加try

This commit is contained in:
wangxiaowei 2024-09-29 14:11:38 +08:00
parent cc568d5057
commit de082bc9b1

@ -323,6 +323,7 @@ class LocalStore extends Api
// 腾讯地图逆编码
public function getLocation()
{
try {
$post = $this->request->post();
$url = 'https://apis.map.qq.com/ws/geocoder/v1?key=' . ConfigServer::get('map', 'tx_map_key') . '&address=' . $post['address'];
$result = file_get_contents($url);
@ -330,7 +331,8 @@ class LocalStore extends Api
if ($data['message'] == 'Success') {
return JsonServer::success('', $data['result']['location']);
}
return JsonServer::error('地理位置获取失败');
} catch(\Exception $e) {
return JsonServer::error($e->getMessage());
}
}
}