Subscribing to Facebook Graph API’s real time updates using CURL.

Facebook allows you to subscribe to an application user’s activity on Facebook, so that you can subscribe to them, and use that information for various things. This is great because (the other alternative is) having to run a daemon process in order to find out a user’s Facebook activity is painful.

However, as awesome as this service is, understanding their documentation on this topic is a whole another matter. I found it almost impossible to decipher, as a lot of things were unclear or left unexplained. Look here:

Luckily I found a blog post explaining how to do this, here it is.

I’ll run down the steps again below, as a few of the steps are now easier:

1. Get access token: gives you access tokens to all your apps on facebook.

2. Check if access token works:

curl "<appid>/subscriptions?access_token=<access token from  step (1)>"

Since you originally have no subscriptions, you get:

{“data”:[]} or some kind of error.

3. If you got empty JSON back in step 2, now you can subscribe to updates(here I want to subscribe to user checkins):

curl -F 'object=user' \
-F 'callback_url=<callback url you have to implement>' \
-F 'fields=checkins' \
-F 'verify_token=<secret token>' \
"<your-app-id>/subscriptions?access_token=<access token from (1)"

The callback_url should be something along the lines of:

This call should return “null” if successful. Once you have subscribed to updates, Facebook starts posting activities of all your application users to the callback_url above.

4. To verify step 3 was successful, run step 2 again, and this time, it should return something like this:


The above response means the subscription to updates about user checkins are now active. Hopefully this helps people who are confused about how to get real time updates working.