Take the 2-minute tour ×

in facebook fql theres this code


curl \
    -F 'access_token=…' \
    -F 'batch=[ \

it suppose to to be sent with json but I really dont understand how to do this any help ?


share|improve this question
Can you be more precise in your question? what have you tried, what did you expected and what is the result you got? have you tried the above command? did it fail? do you have curl installed? did it respond? what did you get? what error message you see? –  PA. Oct 8 '11 at 18:47

3 Answers 3

up vote 3 down vote accepted

You can simple use the BatchFB api its very powerful and easy , you dont have to deal will all of these stuff and it use the fql for example to get all your friends

Later<ArrayNode> friendsArrayList = this.Batcher.query("SELECT uid FROM user WHERE uid  IN (SELECT uid2 FROM friend WHERE uid1 = me())");
    for (JsonNode friend : friendsArrayList.get()) {

and its batched

share|improve this answer

I believe your question is how to execute a batch request using Facebook Graph API. For this you have to issue a POST request to


and the post data to be sent should be

"batch=[{'method': 'GET', 'relative_url': 'me'}, {'method': 'GET', 'relative_url': 'me/friends?limit=50'}]&access_token=@accesstoken" 

in your case [@accesstoken must be replaced with your access token value].

This request will return the details of the owner of the access token(normally the current logged in user) and a list of 50 facebook friends(contains id and name fields) of the user along with page headers(can be omitted).

I am not sure whether you meant java or Javascript. Please be specific on it.

I am a C# programmer basically. Will provide you a code to execute the above request in C# here.

WebRequest webRequest = WebRequest.Create("https://graph.facebook.com");
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-UrlEncoded";
byte[] buffer = Encoding.UTF8.GetBytes("batch=[{'method': 'GET', 'relative_url': 'me'}, {'method': 'GET', 'relative_url': 'me/friends?limit=50'}]&access_token=@ACCESSTOKEN");
webRequest.ContentLength = buffer.Length;
using (Stream stream = webRequest.GetRequestStream())
    stream.Write(buffer, 0, buffer.Length);
    using (WebResponse webResponse = webRequest.GetResponse())
        if (webResponse != null)
            using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8))
                string data = streamReader.ReadToEnd();

Here the variable data will contain the result.

share|improve this answer

Salah, here is the example i use as reference, i am sorry though i do not remember where i found.

FB.api("/", "POST", {
            "omit_response_on_success": true,
            "method": "GET",
}, function(response) {
    if (!response || response.error) {
    } else {    
        /* Iterate through each Response */
        for(var i=0,l=response.length; i<l; i++) {
            /*  If we have set 'omit_response_on_success' to true in the Request, the Response value will be null, so continue to the next iteration */
            if(response[i] === null) continue;
            /*  Else we are expecting a Response Body Object in JSON, so decode this */
            var responseBody = JSON.parse(response[i].body);
            /*  If the Response Body includes an Error Object, handle the Error */
            if(responseBody.error) {
                // do something useful here
            /*  Else handle the data Object */
            else {
                // do something useful here
share|improve this answer

Your Answer


