question

Jens-Stefan avatar image
Jens-Stefan asked

Facebook Instant Game Leaderboard

Hello,

I am developing a Facebook Instant Game with the Defold game engine. I would like to implement a global, never resetting leaderboard. The players play a small session of a game and receive a score (an integer). This score should then be saved to the leaderboard.

I've managed to get saving the score to the leaderboard to work. However now I am not sure how to get the Facebook names of the leaderboard entries.

The way I do the login is by firstly, initiating the FBInstant SDK, then I get the signature, which is required for "LoginWithFacebookInstantGamesId". I then login the player with this function (CreateAccount is set to true). This call is a success and the player is logged in. I then use UpdatePlayerStatistics to insert/update the high score in the leaderboard.

For receiving the display name and avatar URI, I've already set the Client Profile Options in the Playfab dashboard to the correct settings: enabled "Avatar URL", "Display name" and "Statistics".

Now, when I get leaderboard data, using GetFriendLeaderboardAroundPlayer (IncludeFacebookFriends set to true), this is the result (mind you, I currently have just my own entry in there...none of my Facebook friends have played it):

As you can see, this does not include avatar URL, nor the player's display name.

1) Do I have to use one of these IDs (PlayerId, PublisherId, PlayFabId) to then use on the Facebook SDK to somehow get the display name and avatar image? If yes then which id and which Facebook SDK function should I use?

2) In addition to LoginWithFacebookInstantGamesId, do I need to link the created user with facebook using one of the Playfab linking functions? Or do I need to store the facebook name and avatar url to Playfab database manually?

Thanks for the help!

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

·
Sarah Zhang avatar image
Sarah Zhang answered

>> 1) Do I have to use one of these IDs (PlayerId, PublisherId, PlayFabId) to then use on the Facebook SDK to somehow get the display name and avatar image? If yes then which id and which Facebook SDK function should I use?

If you want to get the player’s Facebook display name and the Facebook avatar, you can retrieve them using Facebook SDK directly. PlayFab doesn’t provide such feature to connect Facebook user profile. If you have questions about how to use Facebook API to access the user profile, you can try to contact Facebook developer support for help.

>> 2) In addition to LoginWithFacebookInstantGamesId, do I need to link the created user with facebook using one of the Playfab linking functions? Or do I need to store the facebook name and avatar url to Playfab database manually?

Using LoginWithFacebookInstantGamesId means you linked Facebook Instant Game ID with PlayFab. If you want to link the Facebook account with PlayFab too, you need to call the API LinkFacebookAccount. As the first answer said, you can retrieve the user profile through Facebook API. If so, you needn’t cache them manually.

10 |1200

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

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.