外观
创建卡片消息对象
约 228 字小于 1 分钟
2025-04-44
1. 描述
createCardMessage()
创建卡片消息对象,该方法为同步函数
。
2. 参数
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
conversationType | 是 | TYPE | CONVERSATION_TYPE.GROUP 或 CONVERSATION_TYPE.SINGLE |
target | 是 | String | 接收者ID(单聊用户ID或群聊ID) |
href | 是 | String | 卡片链接 |
imageUrl | 是 | String | 卡片图片URL |
title | 否 | String | 卡片标题,与summary不能同时为空,支持html 模板字符串 |
summary | 否 | String | 卡片摘要,与title不能同时为空,支持html 模板字符串 |
quote | 否 | Object | 引用消息对象,包含完整的消息体 |
at | 否 | JsonArray | 艾特的用户对象数组,只存在于群聊中 |
3. 返回值
返回卡片消息对象。
4. 示例代码
const message = XBCIM.createCardMessage({
target: 'userId',
conversationType: XBCIM.CONVERSATION_TYPE.GROUP,
title: '标题',
summary: '摘要',
href: 'https://www.example.com',
imageUrl: 'https://www.example.com/image.jpg',
quote: {
id: 'xxxxxx',
... // 完整的消息体
},
at: [
{
userId: 'user-id',
... // 用户对象
},
]
})