From a9b50046c1b4bf508d6e800bff6ea6fd63617d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B1=95=E9=B9=8F?= Date: Fri, 5 Dec 2025 18:18:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4webhook=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=EF=BC=8C=E4=BB=85=E5=9C=A8=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=B6=E8=AE=B0=E5=BD=95=E5=AE=8C=E6=95=B4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webhook.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/webhook.php b/webhook.php index 7e6227c..763ee04 100644 --- a/webhook.php +++ b/webhook.php @@ -82,9 +82,8 @@ $method = $_SERVER['REQUEST_METHOD']; // 获取请求数据 $request_body = file_get_contents('php://input'); -// 记录所有请求 +// 记录所有请求(仅记录方法) log_message("收到请求 - 方法: $method"); -log_message("请求内容: $request_body"); // 处理验证请求 if ($method == 'POST') { @@ -108,7 +107,6 @@ if ($method == 'POST') { // 处理实际的表单数据 log_message("处理表单数据"); - log_message("原始表单数据: " . print_r($data, true), 'data'); // 解析WPS表单数据结构 $form_data = array( @@ -174,8 +172,6 @@ if ($method == 'POST') { } } - log_message("解析后的表单数据: " . print_r($form_data, true), 'data'); - // 在这里可以添加数据处理逻辑,例如: // 1. 将数据保存到数据库 // 2. 发送通知 @@ -233,7 +229,9 @@ if ($method == 'POST') { echo json_encode($response); } else { // 处理非POST请求 + // 在错误时记录完整请求 log_message("不支持的请求方法: $method", 'error'); + log_message("完整请求内容: $request_body", 'error'); http_response_code(405); // 方法不允许 echo json_encode(array('error' => '只支持POST请求')); } @@ -245,6 +243,8 @@ function store_form_data_to_db($form_data) { try { $pdo = get_db_connection(); if (!$pdo) { + // 在错误时记录完整表单数据 + log_message("数据库连接失败,表单数据: " . print_r($form_data, true), 'error'); return false; } @@ -305,7 +305,9 @@ function store_form_data_to_db($form_data) { log_message("表单数据成功存储到数据库,插入ID: " . $pdo->lastInsertId()); return true; } catch (Exception $e) { + // 在错误时记录完整表单数据 log_message("数据存储失败: " . $e->getMessage(), 'error'); + log_message("表单数据: " . print_r($form_data, true), 'error'); return false; } }