function getAccesstopken(){
$appid = 'wx085835d45bae5bc1';
$secret= 'd35c9e49c46d2ed7fbf018949b275367';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
$timeacc = file_get_contents("acctime.txt");
echo $timeacc;
if(empty($timeacc)){
file_put_contents("acctime.txt",100);
getAccesstopken();
}else{
$time = time()-$timeacc;
if(($time/3600)>1){
file_put_contents('acctime.txt',time());
$jsoninfo = curlGet($url);
$access_token = $jsoninfo["access_token"];
$_SESSION['access_token'] = $access_token;
return $access_token;
}else{
return $_SESSION['access_token'];
}
}
}
/*微信服务器端ip*/
function getSeverip(){
//https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN
$access_token = getAccesstopken();
$url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token='.$access_token;
return curlGet($url);
}
$appid = 'wx085835d45bae5bc1';
$secret= 'd35c9e49c46d2ed7fbf018949b275367';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
$timeacc = file_get_contents("acctime.txt");
echo $timeacc;
if(empty($timeacc)){
file_put_contents("acctime.txt",100);
getAccesstopken();
}else{
$time = time()-$timeacc;
if(($time/3600)>1){
file_put_contents('acctime.txt',time());
$jsoninfo = curlGet($url);
$access_token = $jsoninfo["access_token"];
$_SESSION['access_token'] = $access_token;
return $access_token;
}else{
return $_SESSION['access_token'];
}
}
}
/*微信服务器端ip*/
function getSeverip(){
//https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN
$access_token = getAccesstopken();
$url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token='.$access_token;
return curlGet($url);
}