[php]代码库
获得access_token
public function take_access_token(){
$ch = curl_init();
$APPID=C("APPID");
$APPSECRET=C("APPSECRET");
// 2. 设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$APPID}&secret={$APPSECRET}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// 3. 执行并获取HTML文档内容
$output = curl_exec($ch);
// 4. 释放curl句柄
curl_close($ch);
// var_dump($output);
// print_r($output);
echo'<br>';
$arr = json_decode($output,true);
$arr['token_time'] = time();
// var_dump($arr['access_token']);
return($arr);
}