Speed Up your Facebook Application – Graph API Batch Requests

Recently, I have written a Facebook application that needs to get the user’s interests, books, music, movies etc connections via Graph API.

It is not that different as we can simply query the Graph API connection /me/interests, /me/books, /me/movies one-by-one by sending Graph API requests.  However, this will slow down the application.

To solve the issue, I have used Graph API batch request for get all these data at one time!  For details on how to use this batch request feature, you can refer to Facebook documentation here.

As usual, the sample code / commands given by Facebook is written in curl.  This is fair as different people may be working on different languages (PHP, ASP, java). So, if you are not working on curl directly, probably you need to spend some time in getting familiar with how to format the request and interpret the data in the language / SDK that you used. But that is worth!

For me, my application is written in PHP and I use the PHP SDK. Though I can easily transform the sample curl code to PHP code, I still prefer sending the batch request via the PHP SDK (as it provides me with add-on features like throwing out exception in case of error).

As a side note, I think knowing how to read the “curl” sample code would help you to understand Facebook documentation better and eaiser.

This entry was posted in Development Tips and tagged . Bookmark the permalink.

2 Responses to Speed Up your Facebook Application – Graph API Batch Requests

  1. i just saw your comment this is really important to me

  2. Antoine says:

    You seems to be an expert in this field, good article and keep up the great work, my buddy recommended me your blog.

Leave a Reply

Your email address will not be published. Required fields are marked *