# sendTextMessage
发送纯文本到指定会话。
注意事项:
网页应用调用前,需前置成功调用requestAuthCode
# 支持说明
应用能力 | Android | iOS | PC | 预览效果 |
---|---|---|---|---|
小程序 | X | X | X | 待补充 |
网页应用 | 3.16.0 | 3.16.0 | X | 待补充 |
# 输入
继承标准对象输入,扩展属性描述:
注意事项:
- 当前实现版本,ios、安卓仅支持手动选择联系人发送,指定openChatId的方式后续支持
名称 | 数据类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
shouldChooseChat | boolean | 否 | false | 是否在选择会话页面中发送卡片,如果该字段设置为true, 会跳转到选择会话页面并进行后续操作来完成卡片的发送。 openIDs 和 openChatIDs指定的用户跟群聊会自动勾选 |
chooseChatParams | object | 否 | 若 shouldChooseChat 输入为true,则可以定制选择会话的入参,参考选择会话chooseChat。待开发 | |
openChatIDs | string[] | 否 | 开放平台 openChatId (群聊)列表。 示例值:["chatID1","chatID2"] | |
openIDs | string[] | 否 | 开放平台 openid (单聊)列表。不支持指定机器人 示例值:["chatID1","chatID2"] | |
content | string | 否 | 文本内容 |
# 输出
success
返回对象的扩展属性:
名称 | 数据类型 | 描述 |
---|---|---|
errMsg | string | 错误消息。 |
sendCardInfo | string[] | 发送消息卡片的message信息(只有消息发送动作产生时才会返回该字段; 例如没有传 openChatIDs ,用户取消发送,解析卡片内容失败等情况都不会返回该字段)。 |
∟ status | number | 发送消息的状态码,0表示发送成功,1表示发送失败 |
∟ id | string | 单聊 :开放平台openid机器人 :加密的bosshi userid(开放平台目前没有属于机器人的openid)示例: ou_aea5df288c71a47af6ccd786c05be939 |
∟ chatType | number | 会话类型 可选值: 0 :单聊1 :群聊 |
∟ userType | number | 单聊类型 可选值: 0 :普通用户1 :机器人(仅在chatType为0时返回此参数) |
∟ openMessageId | string | open_message_id暂不支持 |
# 示例代码
bz.sendTextMessage({
shouldChooseChat: true,
chooseChatParams: {
"allowCreateGroup": true,
"multiSelect": true,
"externalChat": false,
"confirmTitle": "testTitle"
},
openChatIDs: [],
openIDs: [],
content: "测试文本",
success(res) {
bz.showModal({
title: '成功',
content: JSON.stringify(res)
})
},
fail(res) {
bz.showModal({
title: '失败',
content: JSON.stringify(res)
})
}
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
success
返回对象示例:
{
"sendCardInfo": [
{
"openMessageId": "",
"id": "",
"status": 0,
"chatType": 0,
"userType": 1
}
],
"errMsg": "sendTextMessage:ok"
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12