调整webhook日志级别,仅在错误时记录完整信息
This commit is contained in:
+7
-5
@@ -82,9 +82,8 @@ $method = $_SERVER['REQUEST_METHOD'];
|
|||||||
// 获取请求数据
|
// 获取请求数据
|
||||||
$request_body = file_get_contents('php://input');
|
$request_body = file_get_contents('php://input');
|
||||||
|
|
||||||
// 记录所有请求
|
// 记录所有请求(仅记录方法)
|
||||||
log_message("收到请求 - 方法: $method");
|
log_message("收到请求 - 方法: $method");
|
||||||
log_message("请求内容: $request_body");
|
|
||||||
|
|
||||||
// 处理验证请求
|
// 处理验证请求
|
||||||
if ($method == 'POST') {
|
if ($method == 'POST') {
|
||||||
@@ -108,7 +107,6 @@ if ($method == 'POST') {
|
|||||||
|
|
||||||
// 处理实际的表单数据
|
// 处理实际的表单数据
|
||||||
log_message("处理表单数据");
|
log_message("处理表单数据");
|
||||||
log_message("原始表单数据: " . print_r($data, true), 'data');
|
|
||||||
|
|
||||||
// 解析WPS表单数据结构
|
// 解析WPS表单数据结构
|
||||||
$form_data = array(
|
$form_data = array(
|
||||||
@@ -174,8 +172,6 @@ if ($method == 'POST') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message("解析后的表单数据: " . print_r($form_data, true), 'data');
|
|
||||||
|
|
||||||
// 在这里可以添加数据处理逻辑,例如:
|
// 在这里可以添加数据处理逻辑,例如:
|
||||||
// 1. 将数据保存到数据库
|
// 1. 将数据保存到数据库
|
||||||
// 2. 发送通知
|
// 2. 发送通知
|
||||||
@@ -233,7 +229,9 @@ if ($method == 'POST') {
|
|||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
} else {
|
} else {
|
||||||
// 处理非POST请求
|
// 处理非POST请求
|
||||||
|
// 在错误时记录完整请求
|
||||||
log_message("不支持的请求方法: $method", 'error');
|
log_message("不支持的请求方法: $method", 'error');
|
||||||
|
log_message("完整请求内容: $request_body", 'error');
|
||||||
http_response_code(405); // 方法不允许
|
http_response_code(405); // 方法不允许
|
||||||
echo json_encode(array('error' => '只支持POST请求'));
|
echo json_encode(array('error' => '只支持POST请求'));
|
||||||
}
|
}
|
||||||
@@ -245,6 +243,8 @@ function store_form_data_to_db($form_data) {
|
|||||||
try {
|
try {
|
||||||
$pdo = get_db_connection();
|
$pdo = get_db_connection();
|
||||||
if (!$pdo) {
|
if (!$pdo) {
|
||||||
|
// 在错误时记录完整表单数据
|
||||||
|
log_message("数据库连接失败,表单数据: " . print_r($form_data, true), 'error');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +305,9 @@ function store_form_data_to_db($form_data) {
|
|||||||
log_message("表单数据成功存储到数据库,插入ID: " . $pdo->lastInsertId());
|
log_message("表单数据成功存储到数据库,插入ID: " . $pdo->lastInsertId());
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
// 在错误时记录完整表单数据
|
||||||
log_message("数据存储失败: " . $e->getMessage(), 'error');
|
log_message("数据存储失败: " . $e->getMessage(), 'error');
|
||||||
|
log_message("表单数据: " . print_r($form_data, true), 'error');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user