GroupGetMemberInfoList

功能介绍

获取群成员信息

该接口支持批量获取,您可以一次传入多个 group_get_members_info_list_param_identifier_array 获取多个群成员的资料,从而提升网络传输效率。

普通群(工作群、会议群、公开群、社群)的限制:

group_member_get_info_option_role_flag 只能设置为 TIMGroupMemberRoleFlag 定义的数值,SDK 会返回指定角色的成员。

直播群(AVChatRoom)的限制:

如果设置 group_member_get_info_option_role_flag 为 TIMGroupMemberRoleFlag 定义的数值,SDK 返回全部成员。返回的人数规则为:旗舰版支持拉取最近入群群成员最多 1000 人

如果设置 group_member_get_info_option_role_flag 为群成员自定义标记,旗舰版支持拉取指定标记的成员列表。

群成员资料信息仅支持 userID | nickName | faceURL | role 字段。

参数详解

重载1

参数名称 参数类型 是否必填 描述
json_group_getmeminfos_param GroupGetMemberInfoListParam 获取信息参数
callback ValueCallback< GroupGetMemberInfoListResult > 异步回调 返回值的json_param的格式为json

重载2

参数名称 参数类型 是否必填 描述
json_group_getmeminfos_param GroupGetMemberInfoListParam 获取信息参数
callback ValueCallback< string > 异步回调 返回值的json_param的格式为string

返回模板

TIMResult

调用成功后回调函数参数:
code:int
desc:string
json_param:
'{
  "group_get_memeber_info_list_result_info_array" : [
      {
        "group_member_info_custom_info" : {},
        "group_member_info_identifier" : "user1",
        "group_member_info_join_time" : 1551344977,
        "group_member_info_member_role" : 400,
        "group_member_info_msg_flag" : 0,
        "group_member_info_msg_seq" : 0,
        "group_member_info_name_card" : "",
        "group_member_info_shutup_time" : 0
      }
  ],
  "group_get_memeber_info_list_result_next_seq" : 0
}' // Json Key请参考[GroupGetMemberInfoListResult]
user_data:string

返回值详解

名称 数值类型 描述
TIMResult TIMResult 调用接口的返回值
code int 值为ERR_SUCC表示成功,其他值表示失败。详情请参考 错误码
desc string 错误描述字符串
json_param string Json字符串,不同的接口,Json字符串不一样 Json Key请参考GroupGetMemberInfoListResult
user_data string ImSDK负责透传的用户自定义数据,未做任何处理

代码示例

using UnityEngine;
using UnityEngine.UI;
using com.tencent.im.unity.demo.types;
using com.tencent.imsdk.unity;
using com.tencent.imsdk.unity.types;
using com.tencent.imsdk.unity.enums;
using System;
using com.tencent.im.unity.demo.utils;
using EasyUI.Toast;
using System.Collections;
using System.Collections.Generic;
public class GroupGetMemberInfoList : MonoBehaviour
{
  public Text Header;
  public Dropdown SelectedGroup;
  public Dropdown SelectedRole;
  public Text LastSeq;
  public Text Result;
  public Button Submit;
  public Button Copy;
  private List<string> GroupList;
  public int[] EnumRoleFlag = (int[])Enum.GetValues(typeof(TIMGroupMemberRoleFlag));
  string[] Labels = new string[] { "SelectGroupLabel", "SelectRoleLabel" };
  void Start()
  {
    foreach (string label in Labels)
    {
      GameObject.Find(label).GetComponent<Text>().text = Utils.t(label);
    }
    Header = GameObject.Find("HeaderText").GetComponent<Text>();
    SelectedGroup = GameObject.Find("Group").GetComponent<Dropdown>();
    SelectedRole = GameObject.Find("Role").GetComponent<Dropdown>();
    foreach (string name in Enum.GetNames(typeof(TIMGroupMemberRoleFlag)))
    {
      Dropdown.OptionData option = new Dropdown.OptionData();
      option.text = name;
      SelectedRole.options.Add(option);
    }
    LastSeq = GameObject.Find("LastSeq").GetComponent<Text>();
    LastSeq.text = "0";
    Result = GameObject.Find("ResultText").GetComponent<Text>();
    Submit = GameObject.Find("Submit").GetComponent<Button>();
    Copy = GameObject.Find("Copy").GetComponent<Button>();
    Copy.GetComponentInChildren<Text>().text = Utils.t("Copy");
    Submit.onClick.AddListener(GroupGetMemberInfoListSDK);
    Copy.onClick.AddListener(CopyText);
    SelectedGroup.interactable = true;
    if (CurrentSceneInfo.info != null)
    {
      Header.text = Utils.IsCn() ? CurrentSceneInfo.info.apiText + " " + CurrentSceneInfo.info.apiName : CurrentSceneInfo.info.apiName;
      Submit.GetComponentInChildren<Text>().text = CurrentSceneInfo.info.apiName;
    }
    GroupGetGroupListSDK();
  }

  void GetGroupList(params object[] parameters)
  {
    try
    {
      SelectedGroup.ClearOptions();
      GroupList = new List<string>();
      string text = (string)parameters[1];
      List<GroupBaseInfo> List = Utils.FromJson<List<GroupBaseInfo>>(text);
      foreach (GroupBaseInfo item in List)
      {
        GroupList.Add(item.group_base_info_group_id);
        Dropdown.OptionData option = new Dropdown.OptionData();
        option.text = item.group_base_info_group_id;
        SelectedGroup.options.Add(option);
      }
      if (List.Count > 0)
      {
        SelectedGroup.captionText.text = List[SelectedGroup.value].group_base_info_group_id;
      }
    }
    catch (Exception ex)
    {
      Toast.Show(Utils.t("getGroupListFailed"));
    }
  }

  void GroupGetGroupListSDK()
  {
    TIMResult res = TencentIMSDK.GroupGetJoinedGroupList(Utils.addAsyncStringDataToScreen(GetGroupList));
    print($"GroupGetGroupListSDK {res}");
  }

  void GroupGetMemberInfoListSDK()
  {
    if (GroupList.Count < 1) return;
    var param = new GroupGetMemberInfoListParam
    {
      group_get_members_info_list_param_group_id = GroupList[SelectedGroup.value],
      group_get_members_info_list_param_option = new GroupMemberGetInfoOption
      {
        group_member_get_info_option_role_flag = (TIMGroupMemberRoleFlag)EnumRoleFlag[SelectedRole.value]
      },
      group_get_members_info_list_param_next_seq = Convert.ToUInt64(LastSeq.text)
    };
    TIMResult res = TencentIMSDK.GroupGetMemberInfoList(param, Utils.addAsyncStringDataToScreen(GetResult));
    Result.text = Utils.SynchronizeResult(res);
  }

  void GetResult(params object[] parameters)
  {
    Result.text += (string)parameters[0];
    LastSeq.text = Utils.FromJson<GroupGetMemberInfoListResult>((string)parameters[1]).group_get_memeber_info_list_result_next_seq.ToString();
  }

  void CopyText()
  {
    Utils.Copy(Result.text);
  }
  void OnApplicationQuit()
  {
    TencentIMSDK.Uninit();
  }
}

results matching ""

    No results matching ""