即时通信 IM Web&小程序&uni-app(群成员资料)

chat.getGroupMemberProfile(options)参数 options 为 Object 类型,包含的属性值如下。

相关产品
即时通信 IM 产品页,含版本规格、价格与购买入口。

一、获取群成员资料

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

接口

参数

参数 类型 说明
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 类型,包含的属性值如下:

参数 类型 说明
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 类型,包含的属性值如下:

参数 类型 说明
groupID String 群组 ID 或 话题 ID。
userID String | undefined 可选,不填则修改自己的群成员自定义字段。
memberCustomField Array 群成员自定义字段。数组元素的结构如下:key — String — 自定义字段的 Key。value — 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); // 设置群成员自定义字段失败的相关信息});

赞 (0)
上一篇 4天前
下一篇 4天前