Pulling Friends

Last updated: 2020-03-11 17:50:49

    Feature Description

    • This API is used to pulls full friend data by page.
    • This API does not support pulling profile data.
    • You do not need to specify the fields to be pulled. By default, all standard and custom friend data will be returned.

    API Invocation Description

    Request URL example

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

    Request parameters

    The following table describes only the parameters that are 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 It must be an 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 example

    {
        "From_Account": "id",
        "StartIndex": 0,
        "StandardSequence": 0,
        "CustomSequence": 0
    }

    Request packet fields

    Field Type Attribute Description
    From_Account String Required UserID of the user who wants to pull friend data
    StartIndex Integer Required Start position of a page
    StandardSequence Integer Optional StandardSequence returned for the previous friend data pull. If the value of the StandardSequence field is the same as that in the backend, the backend will not return standard friend data.
    CustomSequence Integer Optional CustomSequence returned for the previous friend data pull. If the value of the CustomSequence field is the same as that in the backend, the backend will not return custom friend data.

    Response packet example

    {
        "UserDataItem": [
            {
                "To_Account": "id1",
                "ValueItem": [
                    {
                        "Tag": "Tag_SNS_IM_AddSource",
                        "Value": "AddSource_Type_Android"
                    },
                    {
                        "Tag": "Tag_SNS_IM_Remark",
                        "Value": "Remark1"
                    },
                    {
                        "Tag": "Tag_SNS_IM_Group",
                        "Value":["Group1","Group2"]
                    },
                    {
                        "Tag": "Tag_SNS_IM_AddTime",
                        "Value": 1563867420
                    },
                    {
                        "Tag": "Tag_SNS_Custom_Test",
                        "Value": "CustomData1"
                    }
                ]
            },
            {
                "To_Account": "id2",
                "ValueItem": [
                    {
                        "Tag": "Tag_SNS_IM_AddSource",
                        "Value": "AddSource_Type_IOS"
                    },
                    {
                        "Tag": "Tag_SNS_IM_Group",
                        "Value":["Group1"]
                    },
                    {
                        "Tag": "Tag_SNS_IM_AddTime",
                        "Value": 1563867425
                    }
                ]
            }
        ],
        "StandardSequence": 88,
        "CustomSequence": 46,
        "FriendNum": 20,
        "CompleteFlag": 1,
        "NextStartIndex": 0,
        "ActionStatus": "OK",
        "ErrorCode": 0,
        "ErrorInfo": "",
        "ErrorDisplay": ""
    }

    Response packet fields

    Field Type Description
    UserDataItem Array The friend object array. Each friend object contains a To_Account field and a ValueItem array.
    To_Account String UserID of the target friend
    ValueItem Array The array for storing friend data. Each array element contains a Tag field and a Value field.
    Tag String The name of the friend field.
    Value String/Integer/Array The value of the friend field. For details, see Relationship Chain Fields.
    StandardSequence Integer Sequence for standard friend data. The client can save Sequence and return it to the backend through the StandardSequence field in the next request.
    CustomSequence Integer Sequence for custom friend data. The client can save Sequence and return it to the backend through the CustomSequence field in the next request.
    FriendNum Integer The total number of friends.
    CompleteFlag Integer The ending tag of a page. A non-zero value indicates that full friend data is pulled.
    NextStartIndex Integer The start position of the next page.
    ActionStatus String The request processing result. OK: succeeded. FAIL: failed.
    ErrorCode Integer The error code. 0: succeeded. Others: failed.
    ErrorInfo String Error details.
    ErrorDisplay String Detailed 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 error occurred. 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 attempt 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