Header ("content-type:text/html; Charset=utf-8 ");
function GetToken ($url) {
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, curlopt_returntransfer,1); Quite critical, this sentence is to let Curl_exec ($ch) Return the result can be assigned to other variables, JSON data manipulation, if there is no such sentence, then curl returned data can not be manipulated (such as Json_decode and other format operations)
Curlopt_returntransfer the information obtained by CURL_EXEC () is returned as a file stream, rather than as a direct output.
curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
curl_setopt ($ch, Curlopt_ssl_verifyhost, false);
return curl_exec ($ch);
$row =curl_getinfo ($ch, Curlinfo_http_code);
}
$row =gettoken ("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxxxxxx& SECRET=1FD56A90SADFASDFXXFSDFSF ");
$obj =json_decode ($row);
Echo $obj->access_token;
Transferred from: http://blog.csdn.net/qq1355541448/article/details/24790683
PHP Curl gets HTTPS encryption protocol request return JSON data for information acquisition