facebookfacebook-graph-apifacebook-fqlfacebook-php-sdkfacebook-batch-request

How to do batch request of fql queries in graph api?


I am having 4-5 fql queries in single function. Each of them taking 2-4 seconds to execute. Total 14-15 seconds are required to execute that whole function. User required to wait for long time. So I want to reduce that processing time. ( There is not well supported multi-threading concept in PHP.)

I have heard of batch request concept in graph api. And I have googled a lot but didn't understand how to use batch request for fql queries in graph api.


Solution

  • Instead of calling each FQL query separately, why not use FQL Multiquery?

    http://developers.facebook.com/docs/reference/rest/fql.multiquery/

    UPDATE Otherwise, if you don't want do use multiquery I think what you're looking for is here. I couldn't find anything more about FQL and Batch.

    curl \
         -F 'access_token=…' \
         -F 'batch=[{ "method": "POST", \
        "relative_url": "method/fql.query?query=select+name+from+user+where+uid=4", \
         }]
    https://graph.facebook.com