Skip to main content

Friends List Functionality

Registration callback

For callback information, see Unity Callback / Unreal Callback.

Discord

tip

You can obtain the Discord friend list without using Discord as a login channel, but you need to call DiscordAuthorize to authorize the Discord account first.

Prerequisites:

  • Players must grant the openid, sdk.social_layer, and email permissions.For details, see OAuth2 Scopes.

Discord's returned friend list is unordered. The Player Network SDK will provide the user's recent online time for game-side sorting.

Parameters:

  • page (int): page number, >0
  • count (int): items per page, >0
INTLAPI.DiscordQueryFriends(1, 10);

Callback: DiscordFriendsResultObserver

Friend information structure: DiscordUserInfo

For more details about Discord's social features, refer to Discord Social SDK.

Epic

Only supports getting platform friends (not in-game friends).

Parameters:

  • page: Page number
  • page_size: Number of friends per page
  • is_in_game: false to get platform friends
// Get platform friends, 10 per page, return page 1
INTLAPI.QueryFriends(1, 10, false, INTLChannel.Epic);

Facebook

You need to apply for user_friends permission in the Facebook Developer Console. You can use it once approval is granted.For further details, please contact the Player Network Assistant.

After approval, use the backend interface /v2/friend/friend_list to obtain the friends list.

Share link

Steam

Supports querying platform friends and in-game friends.In-game friends are friends who recently played together, and may not necessarily be added as friends on the Steam platform.

Prerequisites:

  • Install and run Steam
  • Steam login status is valid

Parameters:

  • page: Page number
  • page_size: Number of friends per page
  • is_in_game:
    • true - get in-game friends
    • false - get platform friends
// Get in-game friends, 10 per page, return page 1
INTLAPI.QueryFriends(1, 10, true, INTLChannel.Steam);

// Get platform friends, 10 per page, return page 1
INTLAPI.QueryFriends(1, 10, false, INTLChannel.Steam);

Friend status

Friend status information is returned in the extra_json field of FriendResult.

"extra_json": {
"persona_state": 0
}

persona_state description:

ValueDescription
0Not logged in
oneLogged in
2Logged in, but busy
3Away automatically
4Away automatically for a long time
5Online, trading
6Online, want to play games
7Online, but shown as offline to friends

Error code

Error codeDescription
1031Steam DLL loading failed
1032Needs to be started from the Steam platform
1033Steam initialization failed (check steam_appid.txt location or if Steam is running)

Switch

Supports querying platform friends and in-game friends.

Parameters:

  • page: Page number (starting from 0)
  • page_size: Number of friends per page (≤300)
  • is_in_game:
    • true - get in-game friends
    • false - get platform friends
INTLAPI.QueryFriends(1, 10, true, INTLChannel.Switch);

Returned data structure:

{
"ret": 0,
"msg": "",
"method_id": 203,
"ret_code": 0,
"ret_msg": "Success",
"lists": [{
"openid": "eb4621e26d73bdab",
"user_name": "xuzhang",
"gender": 0,
"extra_json": "{\"status\":\"0\",\"isFavorite\":\"true\",\"lastPlayedAppId\":\"0\",\"isSameApplication\":\"false\"}"
}]
}

VK

Supports querying platform friends and in-game friends.

Parameters:

  • page: Page number
  • page_size: Number of friends per page
  • is_in_game:
    • true - get in-game friends
    • false - get platform friends
// Get in-game friends
INTLAPI.QueryFriends(1, 10, true, INTLChannel.VK);

// Get platform friends
INTLAPI.QueryFriends(1, 10, false, INTLChannel.VK);

Xbox Series X|S

Only supports getting in-game friends.

INTLAPI.QueryFriends(1, 10, true, INTLChannel.Xbox);

Returned data structure:

{
"ret": 0,
"msg": "",
"method_id": 203,
"ret_code": 0,
"ret_msg": "Success",
"lists": [{
"openid": "10027382",
"user_name": "xuzhang",
"extra_json": "{\"status\":\"Online\"}"
}]
}