200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 获取城市和天气预报

获取城市和天气预报

时间:2021-02-07 16:09:54

相关推荐

获取城市和天气预报

/*** 获取城市天气预报* @return bool|string*/public function get_weather(){$city=$_GET['city'];if(empty($city)){$city= $this->get_city();}$res = file_get_contents("http://api./telematics/v3/weather?location={$city}&output=json&ak=32da004455c52b48d84a3a484c0dbc99");return json(['msg' => 'success','code' => 1,'data' => json_decode($res, true)]);}protected function get_city(){$getIp = getRemoteIPAddress();$content = file_get_contents("http://api./location/ip?ak=enYCQ2yaIIjL8IZfYdA1gi6hK2eqqI2T&ip=120.237.113.106&coor=bd09ll");$json = json_decode($content, true);$place =urlencode($json['content']['address_detail']['city']);return $place;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。