同步群信息修改状态
当群组资料发生变更时,融云即使通讯(IM)将实时把修改状态同步到您的应用服务器。
开通服务
-
调用此接口前,您须在控制台开通信息托管服务。详情请参阅开启用户信息托管。
-
设置群组资料变更的服务器回调地址。
回调方法
请求方法: POST
数据格式: application/json
融云 IM 服务端会在 POST 请求 URL 中添加签名参数,您可通过签名验证调用者身份和数据有效性,详情请参阅服务端回调签名。
正文参数
HTTP 请求正文数据格式为 application/json
,支持以下参数:
参数 | 类型 | 必传 | 说明 |
---|---|---|---|
profiles | JsonArray | 是 | 批量同步群信息变更 |
profiles 结构 | |||
profiles[i].groupId | String | 是 | 群 ID |
profiles[i].groupName | String | 是 | 群名称 |
profiles[i].time | Long | 是 | 修改时间 |
profiles[i].optUserId | String | 否 | 操作的用户 |
profiles[i].groupProfile | JSON | 否 | 群内置信息,为 JSON 格式。具体的 key 请参考下方详情。 |
profiles[i].groupExtProfile | JSON | 否 | 群扩展信息 |
profiles[i].permissions | JSON | 否 | 群权限信息,为 JSON 格式。具体的 key 请参考下方详情。 |
groupProfile
中的 key
如下:
key 值 | 类型 | 长度/取值范围 | 描述 |
---|---|---|---|
introduction | String | 不超过 512 个字符 | 群简介 |
announcement | String | 不超过 1024 个字符 | 群公告 |
portraitUrl | String | 不超过 128 个字符 | 群头像地址 |
permissions
中的 key
如下:
key 值 | 类型 | 长度/取值范围 | 描述 |
---|---|---|---|
joinPerm | Number | 取值范围:
| 加入群权限 |
removePerm | Number | 取值范围:
| 将群成员移出群组权限 |
memInvitePerm | Number | 取值范围:
| 邀请他人入群权限 |
invitePerm | Number | 取值范围:
| 邀请加入群组处理方式 |
profilePerm | Number | 取值范围:
| 修改群资料及权限 |
memProfilePerm | Number | 取值范围:
| 设置群成员资料权限 |
回调代码示例
以下示例假设您在开通服务页面配置的回调接收地址为 http://example.com/group/info/profile/sync.php
。
HTTP
POST /user/profile/sync HTTP/1.1
Host: example.com
Content-Type: application/json
[
{
"groupId":"groupId",
"groupName":"groupName",
"time":1574476797772,
"optUserId":"userId",
"groupProfile": {"introduction":"introduction","portraitUrl":"XXX"},
"groupExtProfile": {"ext_Profile":"testExt"},
"permissions": {"joinPerm":2,"memInvitePerm":1}
},
{
"groupId":"groupId1",
"groupName":"groupName1",
"time":1574476797774,
"optUserId":"userId1",
"groupProfile": {"introduction":"introduction1","portraitUrl":"XXX1"},
"groupExtProfile": {"ext_Profile":"testExt"},
"permissions": {"joinPerm":1,"memInvitePerm":2}
}
]
响应回调请求
提示
- 只要收到 HTTP
200 OK
成功响应,融云服务端即认为状态已同步。 - 如果应答超时 5 秒,融云服务端将重试 2 次。如果仍然失败,则不再同步此条状态。
- 如短时间内发生大面积超时,融云会暂时停止向您的服务器发送回调请求,并于 1 分钟后恢复。