作者:HikariFocus_695 | 来源:互联网 | 2023-08-07 20:07
我想让它每隔7200秒获取一次 下面这个方法为什么不行呢?每次刷新页面都会重新获取一次 这是为什么?
1 2 3 4 5 6 7 8 9 10
| if(isset($_SESSION['access_token'])&&$_SESSION['expire_time']>time()){
return $_SESSION['access_token'];
}else{
$access_token = $this -> access_token();
$url='https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $access_token['access_token'];
$this->curl($url,$data);
$_SESSION['access_token']=$access_token['access_token'];
$_SESSION['expire_time']=time()+7200;
}
echo $_SESSION['access_token']; |