Facebook Real Time Updates (Webhooks)

Explanatory guide on how to use (and not accidentialy fuck up) Facebook WebHooks

January 3, 2018 - 2 minute read -

On some of projects, that i was actively developing, i was required to catch some updates like friends add/delete or events RSVP as fast as possible from Facebook. Digging into Facebook documentation gave me Webhooks documentation.

Facebook Permissions Documentation

Webhooks is pretty straightforward concept:

  1. You setup a back URI on service
  2. Whenever something happens that URI is acessed with some data

First thing, that you should remember: Facebook Documentation, at least about Webhooks (also for setting RSVP, but that is another story to tell), is actually bad.

If you want to catch info about friends updates nor events RSVP updates you should subscribe to User topic, like in docs, and then to events and friends.

Whenever you did everything right, and start to catch some updates, you probably will notice, that updates are coming only from admins, not from testers nor simple users, who installed (login with facebook) an app.

What the problem is actually is? The Problem is in permissions, what you will never find in documentation, you should request permissions for user_events to get updates for User RSVP for Events and also user_friends for friends updates.

After that, you will probably notice, that everything is working fine. Unless, you accidentialy find out, that for RSVP updates facebook sends verb == accept both for interesting and will go RSVPs.

There are some variants to get around that limitation, whenever you get verb == accept, you should validate user relation with another API calls. Yes, calls. One way, to actually fetch all RSVPs of users to event, but that can be huge amount of requests so it can be actually slow nor you will fall into API requests limit.

Another workaround could be found here, is to use special also undocumented endpoints on Facebook Graph API: /eventID/attending/userID, /eventID/maybe/userID, /eventID/declined/userID.

Hope it helps.