tencent cloud

文档反馈

最后更新时间:2023-08-03 17:08:49

    获取群成员资料

    注意
    每次查询的用户数上限是 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 --- 自定义字段的 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); // 设置群成员自定义字段失败的相关信息
    });
    
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持