fix: 修复飞书消息双重编码问题

问题:
1. FeishuNotificationService 中先 json_encode 然后 HttpClient 又 json_encode
2. 导致 emoji 被双重编码,飞书 API 报错 200621

修复:
1. 直接传递数组给 HttpClient,让 HttpClient 统一进行编码
2. HttpClient 中使用 JSON_UNESCAPED_UNICODE 避免 emoji 转义
3. 移除了 FeishuNotificationService 中的中间编码步骤
This commit is contained in:
root
2026-03-01 09:27:58 +08:00
parent a0e2c7b267
commit 8403d24be3
2 changed files with 5 additions and 7 deletions
@@ -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,