I am using restfb to search for connections using search strings. Based on the example on the restfb.com website, searching is just another example of fetching a connection. I have gotten this to work so far. That is, I can search for example "honda" under "me/home" or "me/posts", successively.
What I cannot figure out is how to combine multiple searches (that is, fetch multiple connections) in a single call. For example, I want to search for "honda" under "me/home" as well as under "me/posts", in a single call.
The restfb.com example for fetching multiple objects is given as follows:
FetchObjectsResults fetchObjectsResults = facebookClient.fetchObjects(Arrays.asList("me", "cocacola"), ....
However, I do not seem to see anything like "fetchConnections" that may enable to retrieve multiple connections, and therefore enable me to combine multiple connection searches in one call.
Any ideas on how I can combine multiple fetchConnections in a single call?
Thanks in advance for the help!
Mohammad
You want to use the batch request object. Something such as the following should work
LinkedList<BatchRequest> request = new LinkedList<BatchRequest>();
List<Long> working = new LinkedList<Long>();
BatchRequest temp = new BatchRequest.BatchRequestBuilder("me").parameters(Parameter.with("limit", 20)).build();
BatchRequest.BatchRequestBuilder("cocacola").parameters(Parameter.with("limit", 20)).build();
Then to make the requests just do the following
List<BatchResponse> response = facebookClient.executeBatch(request, Collections.<BinaryAttachment>emptyList());
Replace me and cocacola with the queries you actually want to make. The restfb page documents how to make these batch requests. The main thing to realise is that you can only put 50 requests per batch request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With