GroupGetMemberInfoList

introduction

Get member info list

Call getGroupMembersInfo to get the profile of group members in batches. You can pass in multiple group_get_members_info_list_param_identifier_array at a time to improve network transmission efficiency.

Common group (Work, Meeting, Group, Community) restrictions:

group_member_get_info_option_role_flag can only be enums in TIMGroupMemberRoleFlag and SDK will return specified roles.

AVChatRoom restrictions:

If set group_member_get_info_option_role_flag as enums in TIMGroupMemberRoleFlag and SDK will return all the members. This rule is retriving the latest joined members (Maximum 1000, Ultimate edition only).

If set group_member_get_info_option_role_flag as custom mark, it will retrieve the custom role list (Ultimate edition only).

Group member info only contains userID | nickName | faceURL | role.

Parameter details

overload1

Parameter name Parameter type Required Description
json_group_getmeminfos_param GroupGetMemberInfoListParam Required GroupGetMemberInfoListParam
callback ValueCallback< GroupGetMemberInfoListResult > Required Asynchronous callback The format of json_param in the return value is json

overload2

Parameter name Parameter type Required Description
json_group_getmeminfos_param GroupGetMemberInfoListParam Required GroupGetMemberInfoListParam
callback ValueCallback< string > Required Asynchronous callback The format of json_param in the return value is string

Returned template

TIMResult

The parameters of the callback function after successfully calling the API:
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
}' // For the meaning of Json Key, please refer to [GroupGetMemberInfoListResult]
user_data:string

Return value details

name type description
TIMResult TIMResult Return value of calling API
code int Result error code: Error Codes
desc string The description of the error.
json_param string Json string. Calling different API will get different Json strings. For the meaning of Json Key, please refer to GroupGetMemberInfoListResult
user_data string User-defined data transfered by ImSDK without any processing

Code example

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 ""