question

Kim Strasser avatar image
Kim Strasser asked

How can I get a new friends statistics and profile?

I need to get a new friends statistics and profile immediately after I added the friend to the friendslist with API PlayFabClientAPI.AddFriend. I use FriendTitleDisplayName in the PlayFabClientAPI.AddFriend API call to add the friend to the friendslist.

I use this code to get all friends in the friendslist and their statistics and profile:

var result = await PlayFabClientAPI.GetFriendsListAsync(new GetFriendsListRequest()
{
    IncludeFacebookFriends = false,
    IncludeSteamFriends = false,
    ProfileConstraints = new PlayFab.ClientModels.PlayerProfileViewConstraints()
    {
        ShowStatistics = true,
        ShowDisplayName = true,
        ShowCreated = true,
        ShowLastLogin = true
    }
});

foreach (var entry in result.Result.Friends)
{

}

But I don't know which API I should use to get only one friends statistics and profile. Which client API should I use to get only one friends(the currently added new friend) statistics and profile?

Leaderboards and Statistics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Ivan Cai avatar image
Ivan Cai answered

After successfully adding this friend, you can get the player's profile and statistic through ClientAPI.GetPlayerProfile. But the premise is that you can get the player's PlayFabId, because GetPlayerProfile requires it in the request body of the API.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kim Strasser avatar image Kim Strasser commented ·

I don't know how to get the new friends PlayFabId. In my game, adding a new friend works like this:

1) The player clicks on the friendslist button.

2) I call PlayFabClientAPI.GetFriendsList to get his friends and their statistics and profile.

3) I display a list of his friends in my game.

4) Then, the player can click on another button to add a new friend to his friendslist.

5) I call PlayFabClientAPI.AddFriend after the player entered his new friends display name.

6) Now, I need to get only the new friends statistics and profile so that I can add the new friend in the currently displayed list of friends.

The problem is that the player only knows and enters his new friends display name and not his PlayFabId. How can I call ClientAPI.GetPlayerProfile if I only have the new friends display name?

EDIT:

It works now. I use this code to get the friends PlayFabId:

var result = await PlayFabClientAPI.GetAccountInfoAsync(new GetAccountInfoRequest()
{
    TitleDisplayName = frienddisplayname
});
string friendplayfabid = result.Result.AccountInfo.PlayFabId;
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.