Browse Source

add:id

master
xiaowei 3 years ago
parent
commit
af38736069
  1. 3
      idapi_config.php
  2. 8
      refreshtoken/index.php
  3. 52
      refreshtokenID/index.php

3
idapi_config.php

@ -9,8 +9,7 @@
//define('API_URL', 'https://api.shequ.fanruan.com');
//define('ID_URL', 'https://id.fanruan.com');
define('API_KEY', 'i7hP48WAcuTrmxfN');
define('API_URL', 'http://testapi');
define('API_URL', 'https://testapi.shequ.fanruan.com');
define('ID_URL', 'https://id');
//正式环境 - 通行证

8
refreshtoken/index.php

@ -12,14 +12,14 @@ 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');
$re_login = CallInterface(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,'/');
$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';

52
refreshtokenID/index.php

@ -0,0 +1,52 @@
<?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;
}
?>
Loading…
Cancel
Save