-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgetToken.php
More file actions
34 lines (27 loc) · 920 Bytes
/
getToken.php
File metadata and controls
34 lines (27 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once('token.php');
// if(file_exists('token.txt')){
$file = fopen("token.txt", "r") or exit("无法打开文件!");
// 读取文件每一行,直到文件结尾
while(!feof($file))
{
$a=fgets($file);
$b = json_decode($a);
if(($b->ExpireTime) && ($b->ExpireTime > time())){
// echo('<script>console.log("没过期");</script>');
$arr = array('result'=>'OK','token'=>$b);
echo json_encode($arr);
}else{
echo('<script>console.log("过期");</script>');
$c=json_encode(getToken());
$files = fopen("token.txt", "w") or exit("无法打开文件!");
fwrite($files,$c);
$arr = array('result'=>'OK','token'=>json_decode($c));
echo json_encode($arr);
}
}
fclose($file);
// }else{
// echo '不存在';
// }
?>