Aug 10, 2009 at 9:48 PM

Hello all,

Has anyone got an example of how the batch API works on this toolkit. Doesnt seem to be any documentation or examples and I cant seem to get it working either.

I seem to get a object not set to reference error when I chain multiple API calls. Would love to use this to reduce the latency of processing.



Nov 23, 2009 at 3:22 AM

Hi kirby,

I've been playing with the 3.0 version of the toolkit in an ASP.NET MVC project and the following snippet seems to be working for me. I haven't seen any samples around either.

Hope this helps.

// Setup a connect session 
var oConnectSession = new Facebook.Session.ConnectSession(APIKEY, SECRET);

// Session key is taken from cookie (as this is for an iframe app, 
// however if offline access is enabled you might get this a database where
// you store the infinite session key.
// Note: This is only required as the Users.HasAppPermission call requests 
//       a user session.
oConnectSession.SessionKey = this.Request.Cookies[string.Format("{0}_session_key", APIKEY)].Value;

// Create API using session from connect session
// Make sure the application in use has a facebook connect URL
Facebook.Rest.Api oApi = new Facebook.Rest.Api(oConnectSession);

// Ensure tasks are queued for a single request

// queue tasks

// execute batch and return list of results
IList<object> oBatchResult = oApi.Batch.ExecuteBatch();

// Assign list items to appropriate variables
// items are returned in the same order they are requested
ViewData["fb_offline_access"] = ((BooleanResponse)oBatchResult[0]).TypedValue;
ViewData["fb_email"] =          ((BooleanResponse)oBatchResult[1]).TypedValue;
ViewData["fb_publish_stream"] = ((BooleanResponse)oBatchResult[2]).TypedValue;
ViewData["fb_read_stream"] =    ((BooleanResponse)oBatchResult[3]).TypedValue;

// Logout of the session 



Oct 25, 2010 at 7:41 AM

Thanks for posting your code. I couldn't find any samples until yours.