Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch requests #28

Open
honi opened this issue Apr 25, 2012 · 1 comment
Open

Batch requests #28

honi opened this issue Apr 25, 2012 · 1 comment

Comments

@honi
Copy link

honi commented Apr 25, 2012

Is there a way to issue batch requests?

I've tried get_objects() which successfully retrieves several objects. But I can't seem to retrieve in one request several object/connection.

For example, if ['1','2'] are album ids, get_objects(['1','2']) successfully gives me those 2 albums. But I can't seem to do something like get_objects(['1/photos','2/photos'])

@martey
Copy link
Member

martey commented May 7, 2012

The library does not currently have any explicit methods for batch API requests (the get_objects method only returns multiple objects, not "connections" like an album's photos), but it is possible to construct them.

Using the PHP code on the Facebook blog post announcing batching, I was able to construct this Python example:

>>> from facebook import GraphAPI
>>> graph = GraphAPI("access-token-goes-here")
>>> batched_requests = '[{"method":"GET","relative_url":"me"},{"method":"GET","relative_url":"me/friends?limit=50"}]'
>>> graph.request("", post_args = {"batch":batched_requests})
[redacted information about Martey and 50 of his friends]

I could see that a method to make this easier, or a way to put GraphAPI objects into "batch mode" (where all calls are stored, and sent as a batch request when needed) would be useful, so I will keep this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants