Hi Mohamed. It seems every day I think about this topic more and have another idea to share. :-) This time, I thought I’d describe the full use case I have in mind (which probably applies to other developers too), why I think it’s unfortunately impractical to do with the current APIs, and some ideas how to make it practical.
The use case is to have users register to Corona Cloud only through the facebook method, not via the email/username/password method, and then to display leaderboards showing just the current user and their facebook friends who use the app.
My understanding is that showing a leaderboard with just the current user and their facebook friends who use the app would be impractical to implement with the current APIs. I think it would have to go something like this, the first two steps being the impractical ones:
- Retrieve the entire leaderboard (a potentially impractically large file, since it’ll contain data on all users who’ve ever submitted a score). This will return a table with the Corona Cloud user_id for each user in the leaderboard
- For every user_id from step 1, retrieve that user’s profile (a potentially enormous and impractical number of network calls; also, this API appears to be missing from corona-cloud-core). This will give us their facebook_id
- Retrieve the user’s facebook friends, either through facebook directly or through the cloud API. (If through facebook directly, the facebook graph API let’s you see which users have installed the app using the “installed” field, which is handy)
- Cross-reference the facebook friend IDs from step 3 with the facebook_id’s from step 2 to get the scores for just the current user’s facebook friends
If I’m missing an easier way to accomplish this using the current APIs, I’d be very interested to hear!
Meantime, here are some ideas of how to make this practical:
- In step 1, the results set from the leaderboard could/should include the facebook_id for each user, if available. That would eliminate the need for step 2 (which is by far the most expensive step)
- In step 1, allow the API to accept filter criteria for retrieving a subset of the leaderboard, like I mentioned above. I mentioned filtering by score range, rank range, and list of user_id’s. It could also filter by list of facebook_id’s
If both of these were implemented, the whole process would become very practical. One would retrieve the current user’s facebook friends who have the app installed through facebook (using the “installed” field in the graph API), request the leaderboard scores for just those individuals using their facebook_id’s (a small and practical number), and get a results set (also small) from Corona Cloud that included each user’s facebook_id as a field (allowing one to cross-reference back to any other info from facebook).
Of course, there could also be a single convenience API that does this all in one step (since Corona Cloud gets the facebook auth token). But I think it’s pretty compelling to give developers a leaderboard API with flexible filter criteria so that it can cover a whole range of use cases besides just this one.
Thanks!