* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App\Services; class TencentMapService { private $key = 'XZ6BZ-TFK2R-L53WL-WYB2F-ZSRIO-VCBNX'; public function geocoder($lat, $lng) { $key = $this->key; $url = "https://apis.map.qq.com/ws/geocoder/v1/?location={$lat},{$lng}&key={$key}"; $client = new \GuzzleHttp\Client(); $data = $client->request('get', $url, [ 'headers' => [ 'Accept' => 'application/json', ] ])->getBody()->getContents(); $data = js2php($data); if ($data['status']) { return false; } return $data['result']; } }