I’m working on developing a node.js app using mongoDB as a database. I’m working on developing fairly simple Facebook integration, and in addition to outsourcing user authentication to FB, I’d like to retrieve a list of the user’s FB friends so that they may later have the option to post to a friend’s wall through the app.
I can’t figure out what exactly is the best way to approach this problem, though. Obviously this information changes fairly often (new friends, etc) – so I can’t simple save the friends to my database the first time a user logs in and then forget about it. At the same time, it seems impractical to fetch the user’s friendslist from FB every time they log in. Another option would be to not save the friendslist at all, and simply send a GET request to Facebook everytime I need it — this could be fairly inefficient though, especially if I develop more integration with FB features. Finally, I’d read about about Facebook’s real-time subscription API — https://developers.facebook.com/docs/reference/api/realtime/. This would allow me to update the friendlist on the fly — but might be a little more work for me to develop.
I assume this is a fairly common challenge, so I was wondering how others tackle this issue, and if there is a sort of “best-practice” way of managing FB information within a stand alone app?
It really depends on what you’ll be using that data for. You can do two things: