Skip to content

机器人批量发送消息

请求URL

https://chat-go.jwzhd.com/open-apis/v1/bot/batch_send?token=016ec8e4d17a4fbda3ccb0e99b44aca0

请求头

bash
Content-Type: "application/json"

请求参数

字段类型是否必填说明
recvIdslist接收消息对象ID
用户: userIds
群: groupIds
recvTypestring接收对象类型
用户: user
群: group
contentTypestring消息类型,取值如下
text/image/file/markdown/html
contentContent对象消息对象
Content对象

contentType为text

字段类型是否必填说明
textstring消息正文
buttonsButton对象列表消息中包括button

contentType为image

字段类型是否必填说明
imageKeystring图片Key, 通过图片上传接口获得
buttonsButton对象列表消息中包括button

contentType为markdown

字段类型是否必填说明
textstringmarkdown字符串
buttonsButton对象列表消息中包括button

contentType为file

字段类型是否必填说明
fileNamestring文件名
fileUrlstring文件URL
buttonsButton对象列表消息中包括button
Button对象
字段类型是否必填说明
textstring按钮上的文字
actionTypeint1: 跳转URL
2: 复制
3: 点击汇报
urlstring当actionType为1时使用
valuestring当actionType为2时,该值会复制到剪贴板
当actionType为3时,该值会发送给订阅端

响应内容

字段类型说明
codeint响应代码
msgstring响应信息,包括异常信息
dataObject返回数据

完整示例

请求示例

bash
curl --location 'https://chat-go.jwzhd.com/open-apis/v1/bot/batch_send?token=016ec8e4d17a4fbda3ccb0e99b44aca0' \
--header 'Content-Type: application/json' \
--data '{
    "recvIds": [
        "307149245",
        "665344168"
    ],
    "recvType": "group",
    "contentType": "text",
    "content": {
        "text": "这里是消息内容",
        "buttons": [
            [
                {
                    "text": "复制",
                    "actionType": 2,
                    "value": "xxxx"
                },
                {
                    "text": "点击跳转",
                    "actionType": 1,
                    "url": "http://www.baidu.com"
                }
            ]
        ]
    }
}'

批量发送文本消息请求示例

json
{
    "recvIds": [
        "307149245",
        "665344168"
    ],
    "recvType": "group",
    "contentType": "text",
    "content": {
        "text": "这里是消息内容",
        "buttons": [
            [
                {
                    "text": "复制",
                    "actionType": 2,
                    "value": "xxxx"
                },
                {
                    "text": "点击跳转",
                    "actionType": 1,
                    "url": "http://www.baidu.com"
                }
            ]
        ]
    }
}

完整响应

json
{
    "code": 1,
    "data": {
        "successCount": 2,
        "successList": [
            {
                "msgId": "0a6b658c079e45d19216b14cd69ba7cc",
                "recvId": "307149245",
                "recvType": "group"
            },
            {
                "msgId": "4c13fee28dfd4a9f8ab886bfe6ceb1f9",
                "recvId": "665344168",
                "recvType": "group"
            }
        ]
    },
    "msg": "success"
}