https://xxxxxx/v4/openim/admin_getroammsg?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
下表仅列出调用本接口时涉及修改的参数及其说明,更多参数详情请参考 REST API 简介。
参数 | 说明 |
---|---|
xxxxxx | SDKAppID 所在国家/地区对应的专属域名:console.tim.qq.com adminapisgp.im.qcloud.com adminapikr.im.qcloud.com adminapiger.im.qcloud.com adminapiind.im.qcloud.com adminapiusa.im.qcloud.com |
v4/openim/admin_getroammsg | 请求接口 |
sdkappid | 创建应用时即时通信 IM 控制台分配的 SDKAppID |
identifier | 必须为 App 管理员帐号,更多详情请参见 App 管理员 |
usersig | App 管理员帐号生成的签名,具体操作请参见 生成 UserSig |
random | 请输入随机的32位无符号整数,取值范围0 - 4294967295 |
contenttype | 请求格式固定值为json |
200次/秒。
例如,用户 user1 和 user2 聊天,现在需要以 user2 的角度查询该会话在2020-03-20 10:00:00 - 2020-03-20 11:00:00内的聊天记录。
{
"Operator_Account":"user2",
"Peer_Account":"user1",
"MaxCnt":100,
"MinTime":1584669600,
"MaxTime":1584673200
}
{
"ActionStatus": "OK",
"ErrorInfo": "",
"ErrorCode": 0,
"Complete": 0,
"MsgCnt": 12, //本次拉取返回了12条消息
"LastMsgTime": 1584669680,
"LastMsgKey": "549396494_2578554_1584669680",
"MsgList": [
{
"From_Account": "user1",
"To_Account": "user2",
"MsgSeq": 549396494,
"MsgRandom": 2578554,
"MsgTimeStamp": 1584669680,
"MsgFlagBits": 0,
"IsPeerRead": 0,
"MsgKey": "549396494_2578554_1584669680",
"MsgBody": [
{
"MsgType": "TIMTextElem",
"MsgContent": {
"Text": "msg 1"
}
}
],
"CloudCustomData": "your cloud custom data"
},
{
"From_Account": "user2",
"To_Account": "user1",
"MsgSeq": 1054803289,
"MsgRandom": 7201,
"MsgTimeStamp": 1584669689,
"MsgFlagBits": 0,
"IsPeerRead": 0,
"MsgKey": "1054803289_7201_1584669689",
"MsgBody": [
{
"MsgType": "TIMTextElem",
"MsgContent": {
"Text": "msg 2"
}
}
],
"CloudCustomData": "your cloud custom data"
},
{ ... } //为节省篇幅,余下的10条消息未列出
]
}
应答中的"Complete": 0
表示该时间范围的消息未全部拉取,需要续拉。
续拉请求中的 MaxTime 应改成应答的 LastMsgTime 字段值,同时填上应答的 LastMsgKey 字段,如下所示:
{
"Operator_Account":"user2",
"Peer_Account":"user1",
"MaxCnt":100,
"MinTime":1584669600,
"MaxTime":1584669680,
"LastMsgKey": "549396494_2578554_1584669680"
}
{
"ActionStatus": "OK",
"ErrorInfo": "",
"ErrorCode": 0,
"Complete": 1,
"MsgCnt": 5, //本次拉取返回了5条消息
"LastMsgTime": 1584669601,
"LastMsgKey": "1456_23287_1584669601",
"MsgList": [
{
"From_Account": "user1",
"To_Account": "user2",
"MsgSeq": 1456,
"MsgRandom": 23287,
"MsgTimeStamp": 1584669601,
"MsgFlagBits": 0,
"IsPeerRead": 1,
"MsgKey": "1456_23287_1584669601",
"MsgBody": [
{
"MsgType": "TIMTextElem",
"MsgContent": {
"Text": "msg 13"
}
}
],
"CloudCustomData": "your cloud custom data"
},
{
"From_Account": "user2",
"To_Account": "user1",
"MsgSeq": 9806,
"MsgRandom": 14,
"MsgTimeStamp": 1584669602,
"MsgFlagBits": 0,
"IsPeerRead": 1,
"MsgKey": "9806_14_1584669602",
"MsgBody": [
{
"MsgType": "TIMTextElem",
"MsgContent": {
"Text": "msg 14"
}
}
],
"CloudCustomData": "your cloud custom data"
},
{ ... } //为节省篇幅,余下的3条消息未列出
]
}
应答中的"Complete": 1
表示该时间范围的消息已全部拉取。
若续拉的应答里 Complete 值为0,表明还需要继续续拉,直到 Complete 值为1。
字段 | 类型 | 属性 | 说明 |
---|---|---|---|
Operator_Account | String | 必填 | 会话其中一方的 UserID,以该 UserID 的角度去查询消息。同一个会话,分别以会话双方的角度去查询消息,结果可能会不一样,请参考本接口的接口说明 |
Peer_Account | String | 必填 | 会话的另一方 UserID |
MaxCnt | Integer | 必填 | 请求的消息条数 |
MinTime | Integer | 必填 | 请求的消息时间范围的最小值(单位:秒) |
MaxTime | Integer | 必填 | 请求的消息时间范围的最大值(单位:秒) |
LastMsgKey | String | 选填 | 上一次拉取到的最后一条消息的 MsgKey,续拉时需要填该字段,填写方法见上方 示例 |
{
"ActionStatus": "OK",
"ErrorInfo": "",
"ErrorCode": 0,
"Complete": 1,
"MsgCnt": 1,
"LastMsgTime": 1584669680,
"LastMsgKey": "549396494_2578554_1584669680",
"MsgList": [
{
"From_Account": "user1",
"To_Account": "user2",
"MsgSeq": 549396494,
"MsgRandom": 2578554,
"MsgTimeStamp": 1584669680,
"MsgFlagBits": 0,
"IsPeerRead": 0,
"MsgKey": "549396494_2578554_1584669680",
"MsgBody": [
{
"MsgType": "TIMTextElem",
"MsgContent": {
"Text": "1"
}
}
],
"CloudCustomData": "your cloud custom data"
}
]
}
{
"ActionStatus": "FAIL",
"ErrorInfo": "Fail to Parse json data of body, Please check it",
"ErrorCode": 90001
}
字段 | 类型 | 说明 |
---|---|---|
ActionStatus | String | 请求处理的结果,OK 表示处理成功,FAIL 表示失败 |
ErrorCode | Integer | 错误码,0表示成功,非0表示失败 |
ErrorInfo | String | 错误信息 |
Complete | Integer | 是否全部拉取,0表示未全部拉取,需要续拉,1表示已全部拉取 |
MsgCnt | Integer | 本次拉取到的消息条数 |
LastMsgTime | Integer | 本次拉取到的消息里的最后一条消息的时间 |
LastMsgKey | String | 本次拉取到的消息里的最后一条消息的标识 |
MsgList | Array | 返回的消息列表 |
MsgFlagBits | Integer | 该条消息的属性,0表示正常消息,8表示被撤回的消息 |
IsPeerRead | Integer | 消息接收方是否发送该条消息的已读回执。0表示未发送,1表示已发送,详情可参考本接口的功能说明。 |
MsgBody | Array | 消息内容,具体格式请参考 消息格式描述(一条消息可包括多种消息元素,MsgBody 为 Array 类型) |
CloudCustomData | String | 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到) |
MsgKey | String | 标识该条消息,可用于 REST API 撤回单聊消息 |
除非发生网络错误(例如502错误),否则该接口的 HTTP 返回码均为200。真正的错误码,错误信息是通过应答包体中的 ErrorCode、ErrorInfo 来表示的。
公共错误码(60000到79999)参见 错误码 文档。
本 API 私有错误码如下:
错误码 | 描述 |
---|---|
90001 | JSON 格式解析失败,请检查请求包是否符合 JSON 规范 |
90003 | JSON 格式请求包体中缺少 To_Account 字段或者 To_Account 字段不是 String 类型 |
90008 | JSON 格式请求包体中缺少 From_Account 字段或者 From_Account 帐号不存在。 |
90009 | 请求需要 App 管理员权限 |
91000 | 服务内部错误,请重试 |
通过 REST API 在线调试工具 调试本接口。
本页内容是否解决了您的问题?