"Public platform development" Baidu Peripheral Search Interface PHP Package
Now the public platform a lot of entertainment, are useful to the surrounding search function, the study is relatively simple, through the Baidu peripheral search interface package as follows:
Call Format:
$wechatBaiduAPI = new Wechatbaiduapi (), $ret = $wechatBaiduAPI->place_search ($str _key, $location [' X ']. ",". $ location[' y ']);
Parameter description:
$query: Search Keywords
$location: Latitude and longitude of geographical location
$radius: Search Radius
Api_server_url = "http://api.map.baidu.com/place/v2/"; $this->auth_params = Array (); $this->auth_params[' ak '] = "11ffd27d38deda622f51c9d314d46b1";} http://api.map.baidu.com/place/search?&query= glasses &location=39.915,116.404&radius=3000&output= Json&key=37492c0ee6f924cb5e934fa08c6b1676public function Place_search ($query, $location, $radius =3000) {return $ This->call ("Search", Array ("Output" =>json, "query" and "=" $query, "Page_size" =>10, "page_num" = 0, "Scope" = > 2, "location" = + $location, "radius" = $radius));} protected function call ($method, $params = Array ()) {$params = Array_merge ($this->auth_params, $params); $url = $this-& Gt;api_server_url. "$method?". Http_build_query ($params); $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_ Returntransfer, true); $data = Curl_exec ($ch); Curl_close ($ch); $result = null; $result = Json_decode ($data, True); return $ Result;}}
Note: The code inside the AK, is Baidu key, each Baidu account has a unique AK, specific self can Baidu!
$this->auth_params[' ak '] = "11ffd27d38deda622f51c9d314d46b1";