你可以使用此接口批量查询会话中的消息。
你可以调用GetConversationMessages接口,指定你所属的AppId、会话 ID、查询起始位置和查询条数批量查询会话中的消息。
一次最多查询 20 条消息。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
QPS 不得超过 100。
使用 POST 方式发起请求。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | GetConversationMessages | 接口名称,本接口取值:GetConversationMessages |
| Version | String | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| AppId | Int | 是 | 000000 | 应用的唯一标志 |
| ConversationShortId | Int | 是 | 000001 | 会话 ID |
| Cursor | Int | 是 | 1666495802476129 | 查询起始位置,即查询起始消息的 Index |
| Limit | Int | 是 | 3 | 查询条数 |
| Reverse | Int | 否 | 0 | 查询方向。
0。值不合法时自动调整为默认值。直播群只能取 1。 |
https://rtc.volcengineapi.com?Action=GetConversationMessages&Version=2020-12-01
postscript{
"AppId":000000,
"ConversationShortId":000001,
"Cursor":1666495802476129,
"Limit":3,
"Reverse":0
}
json返回结果参看 BaseResponse。
其中 Result 的结构如下:
| 参数名 | 类型 | 描述 |
|---|---|---|
| HasMore | Bool | 是否还有下一页 |
| NewCursor | Int | 下一页起始位置 |
| Messages | MessageBody | 消息详细信息 |
{
"ResponseMetadata": {
"RequestId": "Your_RequestId",
"Action": "GetConversationMessages",
"Version": "2020-12-01",
"Service": "rtc",
"Region": "cn-north-1"
},
"Result": {
"HasMore": true,
"NewCursor": 1669694740483825,
"Messages": [
{
"ConversationType": 2,
"ConversationShortId": 000001,
"MessageId": 7171391232210520094,
"MsgType": 10001,
"Content": "Content1",
"Ext": {
"key": "value"
},
"Status": 0,
"CreateTime": 1669723106144,
"Sender": 000010,
"AppId": 000000,
"RefMsgInfo": {
"ReferencedMessageId": 7171391232210503710,
"Hint": "[图片]",
"ReferencedMessageType": 10001,
"Status": 0
},
"IndexInConversation": 1669723106241201
},
{
"ConversationType": 2,
"ConversationShortId": 000001,
"MessageId": 7171391829814806535,
"MsgType": 10001,
"Content": "Content2",
"Ext": {
"key": "value"
},
"Status": 0,
"CreateTime": 1669723123203,
"Sender": 000010,
"AppId": 000000,
"RefMsgInfo": {
"ReferencedMessageId": 7171391232210503710,
"Hint": "[图片]",
"ReferencedMessageType": 10001,
"Status": 0
},
"IndexInConversation": 1669723123272087
},
{
"ConversationType": 2,
"ConversationShortId": 000001,
"MessageId": 7171391829814839303,
"MsgType": 10001,
"Content": "Content3",
"Ext": {
"key": "value"
},
"Status": 0,
"CreateTime": 1669723270194,
"Sender": 000010,
"AppId": 000000,
"RefMsgInfo": {
"ReferencedMessageId": 7171391232210503710,
"Hint": "[图片]",
"ReferencedMessageType": 10001,
"Status": 0
},
"IndexInConversation": 1669723270235453
}
]
}
}
json