You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.8 KiB
70 lines
1.8 KiB
3 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* 自动返回有效access_token
|
||
|
**/
|
||
|
|
||
|
require '../idapi_config.php';
|
||
|
require '../idapi_function.php';
|
||
|
require '../idapi_class_getuser.php';
|
||
|
|
||
|
header("Content-Type: application/json; charset=utf-8");
|
||
|
|
||
|
$get_cookie = $_COOKIE["fr_id_auth"];
|
||
|
if(!$get_cookie){
|
||
|
$str['code']=200;
|
||
|
$str['message']='-1';
|
||
|
$str['data']=[];
|
||
|
$return_json = json_encode($str);
|
||
|
echo $return_json;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
//实例化授权用户
|
||
|
$idNewGetuser = new idapi_getuser();
|
||
|
$id_ckauth = $idNewGetuser->getAuth();
|
||
|
$id_ckauthinfo = $id_ckauth['client'];
|
||
|
|
||
|
|
||
|
//刷新access_token
|
||
|
if($id_ckauthinfo['uid'] && time() > $id_ckauth['expires_time']){
|
||
|
|
||
|
$id_ckuser = id_CKdecrypt($get_cookie);
|
||
|
$id_ckuserinfo = $id_ckuser['client'];
|
||
|
$data = '&appid='.$id_ckuserinfo['appid'].'&uid='.$id_ckuserinfo['uid'].'&refresh_token='.$id_ckuser['refresh_token'];
|
||
|
$re_login = CallInterface(API_URL.'/v1/token/refresh/'.$data,'GET');
|
||
|
$jsonarr = json_decode($re_login,true);
|
||
|
if($jsonarr['message']=='success'){
|
||
|
$new_json = json_encode($jsonarr['data'],JSON_UNESCAPED_UNICODE);
|
||
|
$u_data = id_aes_encrypt($new_json, API_KEY);
|
||
|
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
|
||
|
setcookie('fr_id_auth',$u_data,time()+3600*24*14,'/');
|
||
|
}else{
|
||
|
setcookie('fr_id_auth','',0,'/');
|
||
|
}
|
||
|
|
||
|
$str['code']=200;
|
||
|
$str['message']='success';
|
||
|
$str['data']['access_token'] = $jsonarr['data']['access_token'];
|
||
|
$str['data']['appid'] = $jsonarr['data']['client']['appid'];
|
||
|
$str['data']['uid'] = $jsonarr['data']['client']['uid'];
|
||
|
$str['data']['ref'] = 1;
|
||
|
|
||
|
$return_json = json_encode($str);
|
||
|
echo $return_json;
|
||
|
}else{
|
||
|
$run_json = array (
|
||
|
'access_token' => $id_ckauth['access_token'],
|
||
|
'appid' => $id_ckauthinfo['appid'],
|
||
|
'uid' => $id_ckauth['client']['uid'],
|
||
|
);
|
||
|
echo json_encode($run_json);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
?>
|
||
|
|