前后分离项目使用
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.

53 lines
1.3 KiB

3 years ago
<?php
require '../idapi_config.php';
require '../idapi_function.php';
header("Content-Type: application/json; charset=utf-8");
$get_cookie = $_COOKIE["fr_id_auth"];
if($get_cookie){
$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(NEW_API_URL.'/v1/token/refresh/'.$data,'GET');
$jsonarr = json_decode($re_login,true);
if($jsonarr['code']==200){
$new_json = json_encode($jsonarr['data'],JSON_UNESCAPED_UNICODE);
$u_data = id_aes_encrypt($new_json, API_KEY);
setcookie('fr_id_auth',$u_data,time()+3600*24*14,'/');
$str['code']=200;
$str['message']='success';
$str['data']['id_access_token'] = $jsonarr['data']['access_token'];
$str['data']['id_appid'] = $jsonarr['data']['client']['appid'];
$str['data']['id_uid'] = $jsonarr['data']['client']['uid'];
$str['data']['id_expires_time'] = $jsonarr['data']['expires_time'];
$return_json = json_encode($str);
echo $return_json;
}else{
$str['code']=401;
$str['message']='-1';
$str['data']=[];
$return_json = json_encode($str);
echo $return_json;
}
}else{
$str['code']=401;
$str['message']='-1';
$str['data']=[];
$return_json = json_encode($str);
echo $return_json;
}
?>