From 9b9d1b9b642ecce1b003330ff32119520a1f6ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B1=95=E9=B9=8F?= Date: Tue, 25 Nov 2025 17:46:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(index.php):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E8=AF=B7=E6=B1=82token=E5=8A=A8=E6=80=81=E6=9B=B4=E6=96=B0auth?= =?UTF-8?q?.json=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改index.php逻辑,使其能够根据请求中的token参数动态更新auth.json中的Token字段。同时删除不再使用的url.txt文件。 --- index.php | 17 ++++++++++++----- url.txt | 1 - 2 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 url.txt diff --git a/index.php b/index.php index 68a96ed..b914e87 100644 --- a/index.php +++ b/index.php @@ -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格式错误时的响应 diff --git a/url.txt b/url.txt deleted file mode 100644 index a376441..0000000 --- a/url.txt +++ /dev/null @@ -1 +0,0 @@ -http://wangpu.baison.com.cn/api/sys/devicereg/getaccreditinfo3000j?from=1&tenantcode=0×tamp=20251125170440&token=82DBFF99-D114-4DBD-85E5-3AEE1004A857&version=3.0.3 \ No newline at end of file