_getAddress($id); if(!$update && $sdf['location']) { return array(true, $sdf['location']); } if(!$sdf['address']) { return array(false, '没有地址'); } $param = array( 'key' => AMAP_WEB_KEY, 'address' => $sdf['address'], #如:北京市朝阳区阜通东大街6号 'city' => $sdf['city'], #如北京,不支持县级市 ); $uri = '/v3/geocode/geo'; $api_url = 'https://restapi.amap.com' . $uri . '?' . http_build_query($param); kernel::log("request : \n" . $api_url); $http = new base_httpclient; $rsp = $http->get($api_url); kernel::log("response : \n" . $rsp); $rsp = json_decode($rsp, true); $data = array( 'rsp' => $rsp['status'] == '1' ? 'succ' : 'fail', 'msg' => '' . $rsp['info'].'', 'location' => $rsp['geocodes'][0]['location'], ); $this->_dealResult($data, $sdf); if($data['rsp'] == 'fail') { return array(false, '获取失败:' . $data['msg']); } return array(true, $data['location']); } }