Question

I'm currently developing an app in facebook which has a list of friends of the user logged in and shows their online presence. To get this, I used the following FQL query:

SELECT name,uid, online_presence FROM user WHERE online_presence IN ('active', 'idle') AND uid IN ( SELECT uid2 FROM friend WHERE uid1 = me())

friends_online_presence is an extended permission and returns the Facebook Chat status (a string, one of active, idle, offline or error).

My question is how can I get a real-time update of online-presence change by my friends?

Option 1: Query the Facebook API periodically, in a background process
Option 2: Hook into XMPP to get real-time updates ( an answer from duplicate question below).

People have asked this question before here too, here are some duplicates(unsolved):
facebook-api-real-time-friends-online-presence-update &
Is-it-possible-to-subscribe-to-real-time-updates-for-user-online-presence.

I wanted to know if someone has solved the problem and if yes, how did you solve it.

It'd be great if you could elaborate a bit about the Option 2 (using XMPP/Jabber), because I feel periodically querying would suffice for only a while, when the user count is less.

Was it helpful?

Solution

The best way is to use XMPP.

For integrating facebook chat via XMPP, I think the best way in Rails would be

  1. Rails + StropheJS
  2. In addition to this, you could include something like ember.js (but that's not a necessity)

Overall, the system would look like

StropheJS (client side JS) ----> XMPP BOSH Manager (eJabberd / Punjab) ----> Facebook Servers

In addition to all this, if you are new to XMPP then the book "Professional XMPP Programming with JavaScript and jQuery" is worth a read and has lots of examples with strophejs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top