Batch Paged Requests

I need to retrieve the news feed for a user, and using the Graph API that returns multiple pages. I'd like to get four pages, and that's pretty slow, so I'd like to batch a request for all pages into one request using batching. I can't figure out how to batch-request multiple pages - clearly each request in the batch is dependent on the previous.

I wrote up a webpage to let me test this all out, containing the following form:

<form method="GET" action="https://graph.facebook.com">
<input type="hidden" name="access_token" value="blahblahblah">

<input type="hidden" name="batch" value="[{'method':'GET', 'name':'getnews',
   'omit_response_on_success':false, 'relative_url':'me/home'},{'method':'GET', 
   'relative_url':'{result=getnews:$.paging.next}'}]">

<input type="hidden" name="method" value="post">
<input type="submit">
</form>

Of course, when I get a response from Facebook that requires paging, the paging.next value is a full URL and the batching functionality wants a relative_url, so my first request works and my second request returns with the paging.next URL in a "body" key.

I found a piece of facebook documentation which states that a request like the following works, where you graph.facebook.com is followed by a full URL specifying a request://graph.facebook.com/http://graph.facebook.com/me/home?_fb_url=me/home&access_token=blahblahblah"

I was surprised to find that this works, but it does when I just make that GET request to the Graph API. Unfortunately, the batching functionality does not allow me to put that full URL in the "relative_url" field - it just does that "body" thing.

Does anybody have a good way to batch requests for multiple pages? kongo09 and I were wondering this over in the facebook dev forum, but I guess that's on its way out... http://forum.developers.facebook.net/viewtopic.php?id=107098

Thanks, -Karl

Answers


I have found a way:

You should use

"relative_url":"me/home?after={result=getnews:$.paging.cursors.after}"

Need Your Help

jquery attribute states it is undefined

javascript jquery

I have a bit of code I'm trying to get working, however I seem to be going round in circles at the moment.

Copy dependency to war before packaging

java maven packaging

I'm packaging an ear file with maven for an IBM Content Navigator plugin project. This product requires to have an ear, which includes a war, and that war should include the plugin as jar in the ro...