"WeChat public platform development" Baidu around search interface PHP package

Source: Internet
Author: User
"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";

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.