I have found it useful for speed reasons to issue bulk requests to facebook, and have created a variant of FacebookTemplate that takes a map of ids:
This can be used to fetch a large number of homogenous objects by id from facebook, rather than one by one.Code:public <T> Map<String, T> fetchObjects(Collection<String> objectIds, Class<T> type, MultiValueMap<String, String> queryParameters) { String ids = join(objectIds, ","); URIBuilder uriBuilder = URIBuilder.fromUri(GRAPH_API_URL + "?ids=" + ids); ...
Examples: retrieving the Event details of several events, getting the FacebookProfile of multiple friends at once.
Likewise, multiple ids can be used on a connection, such as retrieving checkin information from multiple friends at once:
Is there any utility in bringing those into the core library?Code:public <T> Map<String,List<T>> fetchMultiConnections(Collection<String> objectIds, String connectionType, Class<T> type, MultiValueMap<String, String> queryParameters) { String connectionPath = connectionType != null && connectionType.length() > 0 ? connectionType : ""; String ids = join(objectIds, ","); URIBuilder uriBuilder = URIBuilder.fromUri(GRAPH_API_URL + connectionPath + "?ids=" + ids); ...
I've implemented those functions, but have not added multi-id variants to all the XYZOperations implementations, since it would double the number of functions.
Thanks,
rbb


Reply With Quote
