首页 > 其他 > 详细

guzzle 对接高德开放平台

时间:2020-04-27 00:08:35      阅读:97      评论:0      收藏:0      [点我收藏+]
        
        // 一般都是 其他数据 入库成功 后 才 更新 经纬度的
        //
发起Http请求 $client = new Client([‘timeout‘ => 5]); //得到URL地址 $url = config(‘gaode.geocode‘); $city = City::findOrFail($fangInfo->fang_city); $url = sprintf($url, $fangInfo->fang_addr, $city->name); //发起请求 $response = $client->get($url); //可尝试 打印$response看看 $body = (string)$response->getBody(); $arr = json_decode($body, true); //如果找到了经纬度,存入数据表 if (count($arr[‘geocodes‘]) > 0) { $locationArr = explode(‘,‘, $arr[‘geocodes‘][0][‘location‘]); $fangInfo->update([ ‘longitude‘ => $locationArr[0], ‘latitude‘ => $locationArr[1] ]); }

 

guzzle 对接高德开放平台

原文:https://www.cnblogs.com/zqblog1314/p/12783262.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!