Pulling a Specified Friend

Last updated: 2020-03-12 09:50:03

    Feature Description

    This API allows you to pull the data and profiles of specified friends.
    We recommend that you pull no more than 100 friends at a time to avoid response packet failure due to excessive data volume.

    API Invocation Description

    Request URL

    https://console.tim.qq.com/v4/sns/friend_get_list?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json

    Request parameters

    The following table lists and describes only the parameters to be modified when this API is invoked. For details on other parameters, see RESTful API Overview.

    Parameter Description
    v4/sns/friend_get Request API
    sdkappid SDKAppID assigned by the IM console when an app is created
    identifier This must be the app admin account. For details, see App Admins.
    usersig The signature generated by the app admin account. For details, see Generating UserSig.
    random Enter a random 32-bit unsigned integer ranging from 0 to 4294967295.

    Maximum invocation frequency

    The maximum invocation frequency is 200 times per second.

    Request packet examples

    • Basic format
      {
        "From_Account":"UserID_1",
        "To_Account":
        [
            "UserID_2"
        ],
        "TagList":
        [
            "Tag_Profile_Custom_Test",
            "Tag_Profile_IM_Image",
            "Tag_Profile_IM_Nick",
            "Tag_SNS_Custom_Test",
            "Tag_SNS_IM_Remark",
            "Tag_SNS_IM_Group"
        ]
      }
    • Batch format
      {
        "From_Account":"UserID_1",
        "To_Account":
        [
            "UserID_2",
            "UserID_3",
            "UserID_4"
        ],
        "TagList":
        [
            "Tag_Profile_Custom_Test",
            "Tag_Profile_IM_Image",
            "Tag_Profile_IM_Nick",
            "Tag_SNS_Custom_Test",
            "Tag_SNS_IM_Remark",
            "Tag_SNS_IM_Group"
        ]
      }

    Request packet fields

    Field Type Attribute Description
    From_Account String Required The UserID of the specified user who wants to pull friend data.
    To_Account Array Required The list of friend UserIDs.
    We recommend that you pull no more than 100 friends at a time to avoid response packet failure due to excessive data volume.
    TagList Array Required This specifies the following profile fields and friend fields to be pulled:
  • Standard profile fields
  • Custom profile fields
  • Standard friend fields
  • Custom friend fields
  • .

    Response packet examples

    • Basic format and complete format

      {
        "InfoItem": [
            {
                "To_Account": "UserID_2",
                "SnsProfileItem": [
                    {
                        "Tag": "Tag_SNS_IM_Remark",
                        "Value": "remark_2"
                    },
                    {
                        "Tag": "Tag_SNS_IM_Group",
                        "Value": ["group1","group2"]
                    },
                    {
                        "Tag": "Tag_Profile_IM_Nick",
                        "Value": "nick_2"
                    },
                    {
                        "Tag": "Tag_SNS_Custom_Test",
                        "Value": "custom_sns_2"
                    },
                    {
                        "Tag": "Tag_Profile_Custom_Test",
                        "Value": "custom_profile_2"
                    }
                ],
                "ResultCode": 0,
                "ResultInfo": ""
            }
        ],
        "ActionStatus": "OK",
        "ErrorCode": 0,
        "ErrorInfo": "",
        "ErrorDisplay": ""
      }
    • Pulling specified friends in batches

    {
        "InfoItem": [
            {
                "To_Account": "UserID_2",
                "SnsProfileItem": [
                    {
                        "Tag": "Tag_SNS_IM_Remark",
                        "Value": "remark_2"
                    },
                    {
                        "Tag": "Tag_SNS_IM_Group",
                        "Value": ["group1","group2"]
                    },
                    {
                        "Tag": "Tag_Profile_IM_Nick",
                        "Value": "nick_2"
                    },
                    {
                        "Tag": "Tag_SNS_Custom_Test",
                        "Value": "custom_sns_2"
                    },
                    {
                        "Tag": "Tag_Profile_Custom_Test",
                        "Value": "custom_profile_2"
                    }
                ],
                "ResultCode": 0,
                "ResultInfo": ""
            },
            {
                "To_Account": "UserID_3",
                "SnsProfileItem": [
                    {
                        "Tag": "Tag_SNS_IM_Remark",
                        "Value": "remark_3"
                    },
                    {
                        "Tag": "Tag_Profile_IM_Nick",
                        "Value": "nick_3"
                    },
                    {
                        "Tag": "Tag_Profile_Custom_Test",
                        "Value": "custom_profile_3"
                    }
                ],
                "ResultCode": 0,
                "ResultInfo": ""
            },
            {
                "To_Account": "UserID_4",
                "ResultCode": 30001,
                "ResultInfo": "Err_SNS_FriendGetList_Friend_Not_Exist"
            }
        ],
        "Fail_Account": [
            "UserID_4"
        ],
        "ActionStatus": "OK",
        "ErrorCode": 0,
        "ErrorInfo": "",
        "ErrorDisplay": ""
    }

    Response packet fields

    Field Type Description
    InfoItem Array The friend object array. Each friend object includes a To_Account field and an SnsProfileItem array.
    To_Account String The UserID of the friend.
    SnsProfileItem Array The array for storing friend data. Each array element includes a Tag field and a Value field.
    Tag String The name of the field.
    Value String/Integer/Array The value of the field.
    ResultCode Integer The processing result of To_Account. 0: succeeded. Others: failed.
    ResultInfo String The error description for To_Account. This field is empty if the processing was successful.
    Fail_Account Array The list of UserIDs for which the processing failed. This field is returned only when the processing fails for a user.
    ActionStatus String The request processing result. OK: succeeded. FAIL: failed.
    ErrorCode Integer The error code. 0: succeeded. Others: failed.
    ErrorInfo String The detailed error information.
    ErrorDisplay String The detailed error information to be displayed on the client.

    Error Codes

    Unless a network error (such as error 502) occurs, the HTTP return code for this API is always 200. ErrorCode and ErrorInfo in the response packet represent the actual error code and error information, respectively.
    For common error codes (60000 to 79999), see Error Codes.
    The following table describes the error codes specific to this API.

    Error Code Description
    30001 A request parameter is incorrect. In this case, check request parameters based on the error description.
    30003 The requested user account does not exist.
    30004 The request requires app admin permissions.
    30006 An internal server error occurred. In this case, try again.
    30007 The network connection timed out. In this case, try again later.

    API Commissioning Tool

    Use the RESTful online commissioning tool for APIs to commission this API.

    References

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help