FriendshipGetFriendProfileList

introduction

Get friend's profile list

This returns all friend's profile FriendProfile.

What should I do if the user profile obtained in the Enhanced edition is not the latest?

Friend's profile: When the profile of a friend is updated, the backend will send a system notification to the SDK, so the profile will be updated in real time.

Non-friend user's profile: When the profile of a non-friend user is updated, the backend cannot send a system notification to the SDK; therefore, the profile cannot be updated in real time. To avoid sending a network request to the backend every time the user profile is obtained, the SDK adds the caching logic and allows a user to pull the profile from the backend every ten minutes.

Parameter details

overload1

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

overload2

Parameter name Parameter type Required Description
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:
'[
  {
      "friend_profile_add_source" : "AddSource_Type_android",
      "friend_profile_add_time" : 1562229520,
      "friend_profile_add_wording" : "",
      "friend_profile_group_name_array" : [],
      "friend_profile_identifier" : "asd12341",
      "friend_profile_item_custom_string_array" : [
        {
            "friend_profile_custom_string_info_key" : "Tag_Profile_Custom_Str",
            "friend_profile_custom_string_info_value" : "qcloud"
        }
      ],
      "friend_profile_remark" : "",
      "friend_profile_user_profile" : {
        "user_profile_add_permission" : 0,
        "user_profile_birthday" : 20190419,
        "user_profile_face_url" : "faceUrl",
        "user_profile_gender" : 0,
        "user_profile_identifier" : "asd12341",
        "user_profile_item_custom_string_array" : [
            {
              "user_profile_custom_string_info_key" : "Tag_Profile_Custom_Str",
              "user_profile_custom_string_info_value" : "qcloud"
            }
        ],
        "user_profile_language" : 1,
        "user_profile_level" : 3,
        "user_profile_location" : "sz\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
        "user_profile_nick_name" : "nick_test23",
        "user_profile_role" : 4,
        "user_profile_self_signature" : "sig_test"
      }
  },
  {
      "friend_profile_add_source" : "AddSource_Type_Android",
      "friend_profile_add_time" : 1555659941,
      "friend_profile_add_wording" : "",
      "friend_profile_group_name_array" : [],
      "friend_profile_identifier" : "lttest1",
      "friend_profile_remark" : "",
      "friend_profile_user_profile" : {
        "user_profile_add_permission" : 0,
        "user_profile_birthday" : 0,
        "user_profile_face_url" : "",
        "user_profile_gender" : 0,
        "user_profile_identifier" : "lttest1",
        "user_profile_language" : 0,
        "user_profile_level" : 0,
        "user_profile_location" : "",
        "user_profile_nick_name" : "",
        "user_profile_role" : 0,
        "user_profile_self_signature" : ""
      }
  }
]'// For the meaning of Json Key, please refer to [FriendProfile]
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 FriendProfile
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.Linq;
using com.tencent.im.unity.demo.utils;
using System.Collections.Generic;

public class FriendshipGetFriendProfileList : MonoBehaviour
{
  public Text Header;
  public Text Result;
  public Button Submit;
  public Button Copy;
  public List<string> ResultText;
  private string Data;

  void Start()
  {
    Result = GameObject.Find("ResultText").GetComponent<Text>();
    Header = GameObject.Find("HeaderText").GetComponent<Text>();
    Submit = GameObject.Find("Submit").GetComponent<Button>();
    if (CurrentSceneInfo.info != null)
    {
      Header.text = Utils.IsCn() ? CurrentSceneInfo.info.apiText + " " + CurrentSceneInfo.info.apiName : CurrentSceneInfo.info.apiName;
      Submit.GetComponentInChildren<Text>().text = CurrentSceneInfo.info.apiName;
    }
    Copy = GameObject.Find("Copy").GetComponent<Button>();
    Copy.GetComponentInChildren<Text>().text = Utils.t("Copy");
    Submit.onClick.AddListener(FriendshipGetFriendProfileListSDK);
    Copy.onClick.AddListener(CopyText);
  }
  void FriendshipGetFriendProfileListSDK()
  {
    TIMResult res = TencentIMSDK.FriendshipGetFriendProfileList(Utils.addAsyncStringDataToScreen(GetResult));
    Result.text = Utils.SynchronizeResult(res);
  }

  void GenerateResultText()
  {
    var Parent = GameObject.Find("ResultPanel");
    foreach (Transform child in Parent.transform)
    {
      GameObject.Destroy(child.gameObject);
    }
    foreach (string resultText in ResultText)
    {
      var obj = Instantiate(Result, Parent.transform);
      obj.text = resultText;
    }
  }

  void GetResult(params object[] parameters)
  {
    ResultText = new List<string>();
    // ArgumentException: Mesh can not have more than 65000 vertices
    // Deal with a single Text cannot render too many words issue
    string CallbackData = (string)parameters[0];
    string[] DataList = CallbackData.Split('\n');
    int count = 0;
    while (count < DataList.Length)
    {
      // Every 400 lines render a new Text
      int end = count + 400;
      if (end > DataList.Length)
      {
        end = DataList.Length;
      }
      string[] textList = DataList.Skip(count).Take(end - count).ToArray();
      ResultText.Add(string.Join("\n", textList));
      count = end;
    }
    Data = (string)parameters[0];
    GenerateResultText();
  }

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

results matching ""

    No results matching ""