Rest接口管理员撤回消息 - IM即时通讯
接口功能
管理员撤回消息,私聊消息根据聊天双方的userId撤回,群聊根据groupId撤回。
撤回成功后,会触发客户端的GoEasy.IM_EVENT.MESSAGE_RECALLED事件,用于帮助开发者更新消息列表,详情请参考客户端撤回文档。
调用说明
URL:
Post https://{rest-host}/v2/im/history/recall
REST Host
杭州: rest-hz.goeasy.io
新加坡: rest-singapore.goeasy.io
撤回私聊消息参数JSON格式
{
"appkey": "BC-xxx",
"recaller": {
"id": "user001",
"data": {"avatar": "/static/images/Avatar-2.png", "name": "Wallace"}
},
"userAId": "user001",
"userBId": "user002",
"messages": [//要撤回消息的timestamp
1581111111111,
1582222222222,
1583333333333
]
}
撤回群聊消息参数JSON格式
{
"appkey": "BC-xxx",
"recaller": {
"id": "user001",
"data": {"avatar": "/static/images/Avatar-2.png", "name": "Wallace"}
},
"groupId": "group001",
"messages": [ //要撤回消息的timestamp
1581111111111,
1582222222222,
1583333333333
]
}
参数字段说明
参数 | 类型 | 必须 | 描述 |
---|---|---|---|
rest-host | String | 是 | 根据您创建应用的区域选择 杭州:rest-hz.goeasy.io 新加坡:rest-singapore.goeasy.io |
appkey | String | 是 | common key 或者 rest key |
recaller.id | String | 否 | 非必填,撤回方id,将会出现在撤回成功的消息对象里 |
recaller.data | String | 否 | 非必填,撤回方数据,将会出现在撤回成功的消息对象里 |
userAId | String | 否 | 私聊双方其中一方的userId,必须与userBId成对传入,不区分发送方和接收方,不得与groupId同时存在 |
userBId | String | 否 | 私聊双方其中一方的userId,必须与userAId成对传入,不区分发送方和接收方,不得与groupId同时存在 |
groupId | String | 否 | 群聊的groupId,不得与userAId/userBId同时存在 |
messages | Long[] | 否 | 要撤回消息的时间戳列表,每次最多撤回20条消息 |
调用示例
//撤回私聊消息
curl -X POST -H "Content-Type: application/json" \
https://rest-hz.goeasy.io/v2/im/history/recall \
-d '{
"appkey": "BC-xxx",
"recaller": {
"id": "user001",
"data": {"avatar": "/static/images/Avatar-2.png", "name": "Wallace"}
},
"userAId": "user001",
"userBId": "user002",
"messages": [ //要撤回消息的timestamp
1581111111111,
1582222222222,
1583333333333
]
}'
//撤回群聊消息
curl -X POST -H "Content-Type: application/json" \
https://rest-hz.goeasy.io/v2/im/history/recall \
-d '{
"appkey": "BC-xxx",
"recaller": {
"id": "user001",
"data": {"avatar": "/static/images/Avatar-2.png", "name": "Wallace"}
},
"groupId": "group001",
"messages": [ //要撤回消息的timestamp
1581111111111,
1582222222222,
1583333333333
]
}'
返回说明
成功返回值示例
{
"code":200,
"content":"OK"
}
失败返回值示例
{
"code":401,
"content":"Unauthorized"
}