On the Internet to write the data wrote a need for PHP curl function, call is Baidu API get data: function GetData ($add) {
$post _data = Array (' AK=KKKK ', ' callback=renderoption ', ' Output=json ', ' city=xxx, ' address= '. $add); Parameter assembly of the transmission
Print_r ($post _data);
$post _data = Implode (' & ', $post _data);
$url = ' http://api.map.baidu.com/geocoder/v2/? '; Route assembly, the parameters you need do not need to be put here, the above assembly is OK.
Here is some initialization of curl, see PHP manual here.
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_post, 1);
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_postfields, $post _data);
Ob_start ();
Curl_exec ($ch); Perform Curl
$result = Ob_get_contents (); Get content
Ob_end_clean ();
Return Json_decode ($result)->result->location;
}
Curl PHP Script Example