I'm developing an app (Flash/AS3) that connects to Facebook. After the user logs in I need to get his friends list (IDs only), check if any of them is a user of my app (through a registry on a database), update the list by adding a flag to every user that is also an app user and then do stuff with the updated list. My question is:
or
notes: - I'm using PHP/cURL to make requests to the Graph API - MySQl Database - I will probably also be checking for Twitter and G+ friends for every user (so the script could take even more time, although I could go through each network in sepparate steps)
What do you think is the best approach? I don't mind having a "loading" period in the application. At this point, I already have the first approach almost completed but a colleague suggested the second one so that the app user wouldn't have to wait for Facebook/Twitter/G+/script response. But... isn't that a waste of resources? I mean, Facebook, etc already have the users/friends connections...would I gain anything by replicating that in my own DB and having cron jobs doing the updates hidden from the app users?
Hope I made myself clear! Thanks!
I once faced a similiar problem. You won't be able to update your database routinely because you normally need an active user (=access token) to retrieve that user's friend list. Formerly, you could ask for a permission "offline_access", but this permission is deprecated: https://developers.facebook.com/roadmap/offline-access-removal/
I decided to write all the friends' IDs into a textfile (User-ID as filename: 123456789.txt) on my server during the first start of my app (showing a spinner and a text saying "loading friends..."). Whenever the app was started afterwards, I pulled the IDs out of that file.
You can trigger an update of that file by checking it's creation date. If it's "too old", delete and recreate it after you've read all the friend IDs. That way, the file cache will be created in background and not be noticed by the user.