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

47 lines
1.5 KiB

3 years ago
<?php
/**
* 同步登录应用接口
* 2020.01.31 by xiaowei
*/
if(!defined('IDAPI')) {
exit('Access Denied');
}
require 'idapi_config.php';
require 'idapi_function.php';
require 'idapi_class_getuser.php';
//实例化授权用户
$idNewGetuser = new idapi_getuser();
$id_ckauth = $idNewGetuser->getAuth();
$id_ckauthinfo = $id_ckauth['client'];
$id_getUserinfo = $idNewGetuser->getUserinfo();
//获取资料
if($_COOKIE['fr_id_auth'] && !$_COOKIE['fr_id_userinfo']){
id_user_info($id_ckauthinfo['uid'],$id_ckauthinfo['appid'],$id_ckauth['access_token']);
}elseif($_COOKIE['fr_id_userinfo'] && !$id_getUserinfo['data']['uid']){
id_refresh_token();
id_user_info($id_ckauthinfo['uid'],$id_ckauthinfo['appid'],$id_ckauth['access_token']);
}
//access_token时效
if($id_ckauthinfo['uid'] && time() > $id_ckauth['expires_time']){
id_refresh_token();
}
//每天第一次访问统计
if($_COOKIE["fr_id_auth"] && $_COOKIE["fr_id_addexist_time"] != date('Ymd')){
$addexist_data = ['uid' => $id_ckauthinfo['uid'],'device' => $_COOKIE["fr_id_appname"]];
$addexist_header = ['authentication:'.base64_encode($id_ckauthinfo['appid'].'.'.$id_ckauth['access_token'].'.'.$id_ckauthinfo['uid'])];
3 years ago
$re_addexist = CallInterface(NEW_API_URL.'/v1/user/addexist/','POST',$addexist_data,$addexist_header);
3 years ago
$addexist_jsonarr = json_decode($re_addexist,true);
if($addexist_jsonarr['code']=='201' || $addexist_jsonarr['code']=='200'){
setcookie('fr_id_addexist_time',date('Ymd'),time()+3600*24*365,'/');
}
}
?>