diff --git a/backend/app/service/FeishuNotificationService.php b/backend/app/service/FeishuNotificationService.php index ad6817c..c261bf2 100644 --- a/backend/app/service/FeishuNotificationService.php +++ b/backend/app/service/FeishuNotificationService.php @@ -563,9 +563,6 @@ class FeishuNotificationService $app = $this->getAppConfig(); $token = $this->getAccessToken(); - // 使用 JSON_UNESCAPED_UNICODE 避免 emoji 被转义 - $content = json_encode(['card' => $card], JSON_UNESCAPED_UNICODE); - error_log('📤 发送飞书消息: app_id=' . $app['app_id'] . ', feishu_user_id=' . $feishuUserId); error_log('📦 消息卡片: ' . json_encode($card, JSON_UNESCAPED_UNICODE)); @@ -574,7 +571,7 @@ class FeishuNotificationService [ 'receive_id' => $feishuUserId, 'msg_type' => 'interactive', - 'content' => $content, + 'content' => ['card' => $card], // 直接传递数组,让 HttpClient 进行编码 ], [ 'Authorization: Bearer ' . $token, @@ -714,8 +711,8 @@ class FeishuNotificationService "https://open.feishu.cn/open-apis/im/v1/messages/{$message->message_id}/update", [ 'msg_type' => 'interactive', - // 使用 JSON_UNESCAPED_UNICODE 避免 emoji 被转义 - 'content' => json_encode(['card' => $updatedCard], JSON_UNESCAPED_UNICODE), + // 直接传递数组,让 HttpClient 进行编码 + 'content' => ['card' => $updatedCard], ], [ 'Authorization: Bearer ' . $token, diff --git a/backend/app/util/HttpClient.php b/backend/app/util/HttpClient.php index 1454408..d513404 100644 --- a/backend/app/util/HttpClient.php +++ b/backend/app/util/HttpClient.php @@ -88,7 +88,8 @@ class HttpClient curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); + // 使用 JSON_UNESCAPED_UNICODE 避免 emoji 被转义 + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data, JSON_UNESCAPED_UNICODE)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ?: self::$defaultTimeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);