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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user