refactor(index.php): 根据请求token动态更新auth.json响应

修改index.php逻辑,使其能够根据请求中的token参数动态更新auth.json中的Token字段。同时删除不再使用的url.txt文件。
This commit is contained in:
2025-11-25 17:46:08 +08:00
parent f8b7bfca78
commit 9b9d1b9b64
2 changed files with 12 additions and 6 deletions
+12 -5
View File
@@ -13,16 +13,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
// 定义文件路径
$authFilePath = 'auth.json';
// 忽略请求路径和查询参数,直接返回auth.json文件内容
// 无论访问路径是什么,都返回相同的固定JSON响应
// 从请求中获取token参数
$requestToken = isset($_GET['token']) ? $_GET['token'] : null;
// 检查auth.json文件是否存在
if (file_exists($authFilePath)) {
// 读取JSON文件内容
$jsonContent = file_get_contents($authFilePath);
// 验证JSON格式是否正确
if ($jsonContent && json_decode($jsonContent) !== null) {
// 直接输出JSON内容
echo $jsonContent;
if ($jsonContent && ($jsonData = json_decode($jsonContent, true)) !== null) {
// 如果请求中包含token参数,则替换auth.json中的token
if ($requestToken && isset($jsonData['data']['Token'])) {
$jsonData['data']['Token'] = $requestToken;
}
// 输出更新后的JSON内容
echo json_encode($jsonData, JSON_UNESCAPED_UNICODE);
exit;
} else {
// JSON格式错误时的响应
-1
View File
@@ -1 +0,0 @@
http://wangpu.baison.com.cn/api/sys/devicereg/getaccreditinfo3000j?from=1&tenantcode=0&timestamp=20251125170440&token=82DBFF99-D114-4DBD-85E5-3AEE1004A857&version=3.0.3