同步群操作状态
当应用中发生对群组的操作的时候,包括创建群组、加入群组、踢出用户、用户退出、群组解散、添加管理员、移除管理员、转移群主这些群操作行为时,融云将操作状态实时同步到您的应用服务器。
开通服务
-
调用此接口前,您须在控制台开通信息托管服务。详情请参阅开启用户信息托管。
-
设置群操作状态的服务器回调地址。
回调方法
请求方法: POST
数据格式: application/json
即时通讯服务端会在 POST 请求 URL 中添加签名参数,您可通过签名验证调用者身份和数据有效性,详细参见 服务端回调签名。
正文参数
HTTP 请求正文数据格式为 application/x-www-form-urlencoded
,支持以下 HTTP 表单参数:
参数 | 类型 | 必传 | 说明 |
---|---|---|---|
profiles | JsonArray | 是 | 需要同步的群信息变更 |
profiles 结构 | |||
profiles[i].groupId | String | 是 | 群 ID |
profiles[i].eventType | Number | 是 | 操作类型:
|
profiles[i].time | Long | 是 | 修改时间 |
profiles[i].optUserId | String | 否 | 操作的用户 |
profiles[i].userIds | Array | 否 | 被操作的用户 |
回调代码示例
以下示例假设您在开通服务页面配置的回调接收地址为 http://example.com/group/opt/profile/sync.php。
POST /user/profile/sync HTTP/1.1
Host: example.com
Content-Type: application/json
[
{
"groupId":"groupId",
"eventType":7,
"time":1574476797772,
"optUserId":"userId",
"userIds": ["userId1","userId2"]
},
{
"groupId":"groupId1",
"eventType":5,
"time":1574476797772,
"optUserId":["userId13","userId3"]
}
]