You need to enable JavaScript to run this app.
实时音视频

实时音视频

复制全文
消息查询
分批查询会话中的消息 GetConversationMessages
复制全文
分批查询会话中的消息 GetConversationMessages

你可以使用此接口批量查询会话中的消息。

使用说明

接口行为

你可以调用GetConversationMessages接口,指定你所属的AppId、会话 ID、查询起始位置和查询条数批量查询会话中的消息。

一次最多查询 20 条消息。

调用接口

关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI

注意事项

QPS 不得超过 100。

请求说明

  • 请求方式:POST
  • 请求地址:https://rtc.volcengineapi.com?Action=GetConversationMessages&Version=2020-12-01

请求参数

下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数

Query

参数类型是否必选示例值描述
ActionStringGetConversationMessages接口名称。当前 API 的名称为 GetConversationMessages
VersionString2020-12-01接口版本。当前 API 的版本为 2020-12-01

Body

参数类型是否必选示例值描述
AppIdInteger000000应用的唯一标志
ConversationShortIdLong000001会话 ID
CursorLong1666495802476129查询起始位置,即查询起始消息的 Index
LimitLong3查询条数

Reverse

Integer

0

查询方向。

  • 0:正向查询
  • 1:反向查询
    默认值为 0。值不合法时自动调整为默认值。
    直播群只能取 1

返回参数

下表仅列出本接口特有的返回参数。更多信息请参见返回结构

参数类型示例值描述
HasMoreBooleantrue是否还有下一页
NewCursorLong20下一页起始位置
MessagesArray of MessageBody-消息详细信息

MessageBody

参数类型示例值描述

ConversationType

Integer

1

会话类型

  • 1:单聊。
  • 2:群聊。
ConversationShortIdLong000001会话 ID
MessageIdLong000012消息 ID

MsgType

Integer

10001

消息类型。

  • 10001:文本。
  • 10003:图片。
  • 10004:视频
  • 10005:文件
  • 10006:音频
  • 10012:自定义消息
ContentStringYour_Content消息内容
ExtJSON Map{"key":"value"}消息的扩展字段,key 的数据类型为 String,value 的数据类型为 String。
StatusInteger0消息状态,取值为0,表示消息可见。
CreateTimeLong1669723135771消息创建时间戳,单位为毫秒
SenderLong000010消息发送人 UserId
AppIdInteger000000应用的唯一标志
RefMsgInfoObject of RefMsgInfo-引用消息
IndexInConversationLong1669723135894214消息在会话中的位置
ClientMsgIdString"unique-key"消息客户端Id,如果端上消息发送失败,会进行重试,可通过此字段进行幂等判断

RefMsgInfo

参数类型示例值描述
ReferencedMessageIdLong10005被引用的消息 ID
HintString[图片]消息引用时展示的文本内容

ReferencedMessageType

Integer

10001

被引用的消息类型

  • 10001:文本。
  • 10003:图片。
  • 10004:视频
  • 10005:文件
  • 10006:音频
  • 10012:自定义消息

Status

Integer

0

被引用的消息状态

  • 0:消息可见
  • 1:消息已过期
  • 2:消息(对用户)不可见
  • 3:消息被撤回
  • 4:消息本身可见,后因删除不可见

请求示例

POST https://rtc.volcengineapi.com?Action=GetConversationMessages&Version=2020-12-01

{
    "AppId": 000000,
    "ConversationShortId": 000001,
    "Cursor": 1666495802476129,
    "Limit": 3,
    "Reverse": 0
}

返回示例

{
    "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": 000012,
                "MsgType": 10001,
                "Content": "Content1",
                "Ext": {
                    "key": "value"
                },
                "Status": 0,
                "CreateTime": 1669723106144,
                "Sender": 000010,
                "AppId": 000000,
                "RefMsgInfo": {
                    "ReferencedMessageId": 000013,
                    "Hint": "[图片]",
                    "ReferencedMessageType": 10001,
                    "Status": 0
                },
                "IndexInConversation": 1669723106241201
            },
            {
                "ConversationType": 2,
                "ConversationShortId": 000001,
                "MessageId": 000014,
                "MsgType": 10001,
                "Content": "Content2",
                "Ext": {
                    "key": "value"
                },
                "Status": 0,
                "CreateTime": 1669723123203,
                "Sender": 000010,
                "AppId": 000000,
                "RefMsgInfo": {
                    "ReferencedMessageId": 000013,
                    "Hint": "[图片]",
                    "ReferencedMessageType": 10001,
                    "Status": 0
                },
                "IndexInConversation": 1669723123272087
            },
            {
                "ConversationType": 2,
                "ConversationShortId": 000001,
                "MessageId": 000015,
                "MsgType": 10001,
                "Content": "Content3",
                "Ext": {
                    "key": "value"
                },
                "Status": 0,
                "CreateTime": 1669723270194,
                "Sender": 000010,
                "AppId": 000000,
                "RefMsgInfo": {
                    "ReferencedMessageId": 000013,
                    "Hint": "[图片]",
                    "ReferencedMessageType": 10001,
                    "Status": 0
                },
                "IndexInConversation": 1669723270235453
            }
        ]
    }
}

错误码

您可访问公共错误码,获取更多错误码信息。

最近更新时间:2024.04.17 17:35:51
这个页面对您有帮助吗?
有用
有用
无用
无用