获取access-token
/**
* [getinfo 获取access-token]
* @return [type] [description]
*/
public function getinfo(){
$output=self::get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".self::$appid."&secret=".self::$appsecret);
echo $output;
exit();
}
/**
* [get curl 请求]
* @param [string] $url [路径]
* @return [json] [{"access_token":"xxxxxxxxxx","expires_in":7200}]
*/
public static function get($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
# curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!curl_exec($ch)) {
error_log(curl_error($ch));
$data = '';
} else {
$data = curl_multi_getcontent($ch);
}
curl_close($ch);
return $data;
}
网友评论