amapKey = Env::get('amap_key'); $url = 'https://restapi.amap.com/v5/place/text'; $params = [ 'key' => $this->amapKey, 'keywords' => $keyword, 'page_size' => 1, ]; try { $response = Http::get($url, $params); $data = json_decode($response, true); // dd($data); if (isset($data['status']) && $data['status'] == '1') { return $data['pois']['0'] ?? false; } } catch (\Exception $e) { throw $e; // 这里可以做日志记录 } return false; } /** * 还可以封装更多高德API调用方法 */ }