Sending batch app-to-user request on Facebook

With the release of the “live game feed” on Facebook, game requests and notifications now gets their own real estate on the upper right corner of your screen.   This immediately reminded me of the good old days of “notification war” on Facebook circa 2009.   Applications had free reign over your notifications and many spammy apps went viral by abusing that channel.  At Tribal Crossing, we created a populate polling app that reached 3 million MAU that was in part due to this powerful viral feature.   Oh yes, everyone succumbs to the mystical power of the Red Bubble that screams CLICK ME.

Anyways, Facebook took the app-to-user notifications away, but now it has returned in a different implementation – a much better one IMO.   So we plugged back into app-to-user requests so we can send user individual updates besides going through the application wall.  Each notification requires a Graph API call, and it can take a long time to send millions of these requests.  There is a batch API available, but there wasn’t any good documentation so it took me a bit of time to get it to work.   Here’s the detail on formatting your Graph API calls to send batch app-to-user requests:

First, batch app-to-user request will require an application access token, obtained through this Graph API call (where client_id is your app id, and client_secret is app secret):

After getting the application access token, you can then construct the URL to do the actual batch call.  This is the basic format of the URL for the batch request:<batch json>&method=POST 

One thing the FB documentation doesn’t clearly mention is that you do need to explicitly add a “method=POST” for it to work.   The format of batch parameter is a JSON string that will basically look like this:

[  {'method':'POST',

And of course, urlencode your batch parametr content before making the call.  That’s it!

Sorry I don’t really have the time to do a more thorough write up or post code sample, but hope this post help someone out there to get fight the necessary fight of viral channel so we can all focus more on the execution of those cool and fun ideas. 🙂

This entry was posted in Development. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.