getWxAccessToken
getWxAccessToken方法怎么获得
getWxAccessToken方法怎么获得
2016-08-11
public function get_token(){
//将access_token存入session/cookie中
if($_SESSION['access_token'] && $_SESSION['expire_time']>time()){
return $_SESSION['access_token'];
}else{
$url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$this->appid."&secret=".$this->appsecret;
$json=$this->getCurl($url);
$arr=json_decode($json,true);
$_SESSION['access_token']=$arr['access_token'];
$_SESSION['expire_time']=time()+7200;
return $arr['access_token'];
}
}
举报