define('APPID','wx2xxxxx');
define('APPSECRET','xxxxxxxxxx');
$tokenFile='./tokenFile.txt';
$data=json_decode(file_get_contents($tokenFile));
if($data->expire_timeexpire_time){
$curl=curl_init();
$url='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.APPID.'&secret='.APPSECRET;
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$res=curl_exec($curl);
curl_close($curl);
$access_token=json_decode($res)->access_token;
print_r($access_token);
if($access_token){
$data['expire_time']=time()+7000;
$data['access_token']=$access_token;
$fp=fopen($tokenFile,"w");
fwrite($fp,json_encode($data));
fclose($fp);
}
}else{
$access_token=$data->access_token;
}
这里是错误提示:
Warning:fopen(./tokenFile.txt)[function.fopen]:failedtoopenstream:Permissiondeniedintest.phponline20
Warning:chmod()[function.chmod]:Permissiondeniedintest.phponline21
Warning:fwrite()expectsparameter1toberesource,booleangivenintest.phponline23
Warning:fclose()expectsparameter1toberesource,booleangivenintest.phponline24
分 -->
|