<?php class GaoDeAPI { private $ key = '123456789'; # you use key /** * Address latitude and longitude */ public function getTrapezeAction($address){ if(!$address){ $ Address = 'Changning Area of the Northern Road 268'; } $parameters = '&key='.$this->key.'&address='.$address; $url = 'https://restapi.amap.com/v3/geocode/geo?'.$parameters; $res = $this->getCurl($url); $res = json_decode($res,true); echo '<pre>'; var_dump($res); } /** * Trip planning support car ride public transportation within walking distance truck * The following is the car */ public function GHAction(){ $origin = '121.369838,31.217535'; $destination = '116.4990234375,31.7129811694'; $parameters = '&key='.$this->key.'&origin='.$origin.'&destination='.$destination; $url = 'https://restapi.amap.com/v3/direction/driving?'.$parameters; $res = $this->getCurl($url); $res = json_decode($res,true); echo '<pre>'; var_dump($res); } /** * Return static map UNKNOWN_ERROR */ public function staticMapAction(){ $location = '116.49902,31.71298'; $parameters = '&key='.$this->key.'&location='.$location; $url = 'https://restapi.amap.com/v3/staticmap?'.$parameters; $res = $this->getCurl($url); $res = json_decode($res,true); echo '<pre>'; var_dump($res); } /** * Check the weather need to get adcode city before this */ public function QueryWeatherAction(){ $adcode = '341500'; $parameters = '&key='.$this->key.'&city='.$adcode; $url = 'https://restapi.amap.com/v3/weather/weatherInfo?'.$parameters; $res = $this->getCurl($url); $res = json_decode($res,true); echo '<pre>'; var_dump($res); } function getCurl($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); curl_close ($ch); return $result; } }
High German API docking
Guess you like
Origin www.cnblogs.com/G921123/p/12123785.html
Recommended
Ranking