1
votes

I am trying to build facebook leaderboard in unity3d for android platform. I have seen the facebook api for scores.I have been using the friend smash example . I am able to successfully post the score using :

        var query = new Dictionary<string, string>();
        query["score"] = Instance.score.ToString();
        FB.API("/me/scores", Facebook.HttpMethod.POST, delegate(FBResult r) { Util.Log("Result: " + r.Text); }, query);

I am also able to successfully request the score by using : FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);

But the problem is I get the score for only one user (The user who is logged in). I want a way in which to get the scores of all facebook friends who play the same game.(I think we can put a limit of 20).

How can this be done?

P.S : I have also tried using app42 platform api's but it gives the same result.

3

3 Answers

0
votes

You need the user_friends permission for your app to do that. Use this for debugging: https://developers.facebook.com/tools/explorer/

0
votes

I know this is an old question, but this may help someone else.

When you play your game in the Unity Editor logged in with your Facebook account, your score is saved. But any other user who logs in will not have the score saved because of a required permission not being present. The documentation for the Scores API says:

You can post a score for a player by issuing an HTTP POST request to /USER_ID/scores with a user access_token as long as the player has granted the publish_actions permission for your app.

There are two ways you can do this for testing.

If you create test users in the Facebook console for your game (Roles -> Test Users), you can use them to verify your code works. Create at least two test users, and make them friends in the console. Get a user token for one of them and log into your game using that token in the Unity Editor. Play the game, save the score, and then do the same for the other test user.

You should then see both test users with scores in your game.

Alternately, this answer lists another way to get a test user token with test user permissions.

To make that work with real user accounts on Facebook, you need to request the publish_actions permission in the Facebook console for your game. (Status & Review).

0
votes

I had this same problem. I added a new user for the app but couldn't see his score. It problem turned out to be just a delay in Facebook's servers. I waited half an hour and it started working automatically.