Batch facebook requests with Graph API

You must Login before you can answer or comment on any questions.

Hi, I'm trying to create a batch request for facebook. I was looking at their documentation here but I'm pretty confused on how this would integrate with Ti.Facebook. More specifically, I don't know what I should I put for the path and params arguments on Ti.Facebook.requestWithGraphPath.

Has anyone done this before? Any help would be much appreciated. (Ti SDK 2.1.3RC / iOS)

2 Answers

I would suggest that you post some code for what you have attempted so far

Also there are multiple questions already in the forum and in the KitchenSink examples that explain how the graph API work.

Finally for batching multiple asynchronous calls, I think this sample should help

http://developer.appcelerator.com/question/121373/httpclient-best-practices

— answered 8 months ago by Aaron Saunders
answer permalink
2 Comments
  • I am completely confused???!!! You want to do something in a batch mode but you do not want to loop?? How is that possible?

    — commented 8 months ago by Aaron Saunders

  • Aaron,

    I'm talking about Facebook batch requests. If you look at the Facebook API for batch requests (http://developers.facebook.com/docs/reference/api/batch/) you will see that there is a way to make a single http call and pass a json array with all the operations/data you wish to perform. So yes, this approach is a lot better than looping and making http requests for each operation!

    — commented 8 months ago by Jason Kritikos

I tried the same thing using the following function but it doesnt work...

function facebookMultiplePost(userIDs){
 
    if (Titanium.Network.online == true){
        if(Titanium.Facebook.loggedIn){
            Ti.API.info('FACEBOOK - facebookMultiplePost() EXECUTING');
            var batchRequests = [{"method":"POST", "relative_url":"100002463617383/feed", "body":"message=testing multiple wall posts"}];
 
            Titanium.Facebook.requestWithGraphPath('batch', {"method":"POST", "relative_url":"100002463617383/feed", "body":"message=testing multiple wall posts"}, "POST", function(e) {
            if (e.success) {
                Ti.API.info('FACEBOOK - Success in posting multi-message');
            } else {
                if (e.error) {
                   Ti.API.info('FACEBOOK - ERROR in posting multi-message '+e.error);
                } else {
                    Ti.API.info('FACEBOOK - UNKNOWN response in posting multi-message');
                }
            }
        });
        } else {
            Ti.API.info('FACEBOOK - NOT logged in');
        }
    }
}
I want to post to multiple friend's walls..and I wouldn't want to do it in a loop...

— answered 8 months ago by Jason Kritikos
answer permalink
2 Comments
  • you should use answers for answers, not responses or comments... it makes the thread easier to follow

    — commented 8 months ago by Aaron Saunders

  • You're right Aaron, sorry about that

    — commented 8 months ago by Jason Kritikos

Your Answer

Think you can help? Login to answer this question!