Reputation: 757
I'm using facebook graph API in my Unity Application. What I'm trying to do is to retrieve the users using my application and show the first 20 ones ordered by score.
In the example project "friend smash" there's the following graph API call:
FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);
This, as far as I know, gets 20 users who are using my application. Due to the poor graph API documentation I can't understand if user.limit(20) just returns 20 random users, or ordered with some criteria.
If this call returns random users, do I have to send one query for each friend, sort them by score and show only the first 20 ones to get a proper ranking? (I guess it would be quite query heavy though)
Upvotes: 1
Views: 781
Reputation: 96373
https://developers.facebook.com/docs/games/scores/#read-many-scores:
You can read the set of scores for a player and their friends by issuing an
HTTP GET
request to/APP_ID/scores
with the useraccess_token
for that app. Theuser_friends
permission is required in order to view friends' scores. This returns a list of scores for a player and friends who have authorized the app. The list is sorted by descending score value, so it returns friends with the highest scores first.
(Highlighting by me.)
Upvotes: 1
Reputation: 10740
In Facebook Graph Explorer use following GET request to receive friends with score (descending order):
app/scores?fields=score&limit=20
It should return following Json:
{
"data":
[
{
"score": 1,
"user":
{
"name": "1st Name",
"id": "first_id"
}
},
{
"score": 0,
"user":
{
"name": "2nd Name",
"id": "2nd_id"
}
}
]
}
Upvotes: 1