123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * 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'];
- }
- }
|