添加try
This commit is contained in:
parent
cc568d5057
commit
de082bc9b1
@ -323,14 +323,16 @@ class LocalStore extends Api
|
||||
// 腾讯地图逆编码
|
||||
public function getLocation()
|
||||
{
|
||||
$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);
|
||||
$data = json_decode($result, true);
|
||||
if ($data['message'] == 'Success') {
|
||||
return JsonServer::success('', $data['result']['location']);
|
||||
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);
|
||||
$data = json_decode($result, true);
|
||||
if ($data['message'] == 'Success') {
|
||||
return JsonServer::success('', $data['result']['location']);
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
|
||||
return JsonServer::error('地理位置获取失败');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user