public function test(){
$url= 'https://apis.map.qq.com/ws/geocoder/v1/';
$list = DB::name('address')->where('status',1)->select();
foreach ($list as $key => $value) {
$value['lng']=preg_replace('# #','',$value['lng']);
$value['lat']=preg_replace('# #', '', $value['lat']);
$data_post=array(
'location'=>$value['lat'].','.$value['lng'],
'key'=>"***********************************",
);
$postinfo= $this->http_request($url,$data_post);
$postinfo = json_decode($postinfo,true);
if($postinfo['status'] == 0){
$result_info=$postinfo['result'];
$value['wcity']=$postinfo['result']['address_component']['city'];
$value['warea']=$postinfo['result']['address_component']['district'];
$value['waddress']=$postinfo['result']['address'];
$list[$key]=$value;
DB::NAME('address')->WHERE('id',$value['id'])->update($value);
}else{
dump($postinfo);
dump($value);
exit;
}
}
$this->success('查询成功',$list);
}
// HTTP请求(支持HTTP/HTTPS,支持GET/POST)
public function http_request($url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (! empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
批量坐标逆解析
最新推荐文章于 2023-08-11 16:21:12 发布