腾讯云即时通信IMWeb&小程序&uni-app_AI解决方案_同尘科技

即时通信 IM 2年前 (2023-07-24) 浏览 54

获取群成员资料

注意每次查询的用户数上限是 50。如果传入的数组长度大于 50,则只取前 50 个用户进行查询,其余丢弃。

接口
chat.getGroupMemberProfile(options);
参数

参数 options 为 Object 类型,包含的属性值如下:

Name Type Description
groupID String 群组 ID。
userIDList Array 要查询的群成员用户 ID 列表。
memberCustomFieldFilter Array | undefined 群成员自定义字段筛选。可选,若不填,则默认查询所有群成员自定义字段。
返回值

Promise

示例
let promise = chat.getGroupMemberProfile({  groupID: 'group1',  userIDList: ['user1', 'user2'], // 注意:即使只获取一个群成员的资料,也要用数组类型,例如:userIDList: ['user1']  memberCustomFieldFilter: ['group_member_custom'], // 筛选群成员自定义字段:group_member_custom});promise.then(function(imResponse) {  console.log(imResponse.data.memberList); // 群成员列表}).catch(function(imError) {  console.warn('getGroupMemberProfile error:', imError);});

设置群成员名片

注意1. TencentCloudChat.TYPES.GRP_AVCHATROOM 类型的群组(即直播群)不支持此操作。2. 操作权限说明:群主:可设置所有群成员的名片。管理员:可设置自身和其他普通群成员的群名片。普通群成员:只能设置自身群名片。

接口
chat.setGroupMemberNameCard(options);
参数

参数 options 为 Object 类型,包含的属性值如下:

Name Type Description
groupID String 群组 ID 或 话题 ID。
userID String | undefined 可选,默认修改自身的群名片。
nameCard String 群成员名片。
返回值

Promise

示例
let promise = chat.setGroupMemberNameCard({   groupID: 'group1',   userID: 'user1',   nameCard: '用户名片', });promise.then(function(imResponse) {  console.log(imResponse.data.group); // 设置后的群资料  console.log(imResponse.data.member); // 修改后的群成员资料}).catch(function(imError) {  console.warn('setGroupMemberNameCard error:', imError); // 设置群成员名片失败的相关信息});

设置群成员自定义字段

注意1. TencentCloudChat.TYPES.GRP_AVCHATROOM 类型的群组(即直播群)不支持此操作。2. 普通群成员只能设置自己的自定义字段。

接口
chat.setGroupMemberCustomField(options);
参数

参数 options 为 Object 类型,包含的属性值如下:

Name Type Description
groupID String 群组 ID 或 话题 ID。
userID String | undefined 可选,不填则修改自己的群成员自定义字段。
memberCustomField Array 群成员自定义字段。数组元素的结构如下:key — String — 自定义字段的 Keyvalue — String — 自定义字段的 Value
返回值

Promise

示例
let promise = chat.setGroupMemberCustomField({   groupID: 'group1',   memberCustomField: [{key: 'group_member_test', value: 'test'}], });promise.then(function(imResponse) {  console.log(imResponse.data.group); // 修改后的群资料  console.log(imResponse.data.member); // 修改后的群成员资料}).catch(function(imError) {  console.warn('setGroupMemberCustomField error:', imError); // 设置群成员自定义字段失败的相关信息});



对即时通讯IM解决方案有疑惑?想了解解决方案收费? 联系解决方案专家

腾讯云限时活动1折起,即将结束: 马上收藏

同尘科技为腾讯云授权服务中心,购买腾讯云享受折上折,更有现金返利:同意关联,立享优惠

阿里云解决方案也看看?: 点击对比阿里云的解决方案

- 0人点赞 -

发表点评 (0条)

not found

暂无评论,你要说点什么吗?