[英]Restfb - Using the Batch Request API
This is my FQL. 这是我的FQL。 What it does is it receives the post based on post_id, and also returns if post was made by user or page. 它所做的是接收基于post_id的帖子,并且还返回帖子是由用户还是页面创建的。 User or page is returned based on id of the one who posted the post, which is returned by first FQLQuery. 根据发布帖子的ID返回用户或页面,该ID由第一个FQLQuery返回。
StringBuilder fqlQuery = new StringBuilder();
fqlQuery.append("SELECT "
+ FacebookGraphApi.FQL_STREAM_SELECT
+ " FROM stream WHERE post_id=\"");
fqlQuery.append(rmtId);
fqlQuery.append("\"");
HashMap<String, String> querys = new HashMap<String, String>();
querys.put("messages", fqlQuery.toString());
querys.put(
"users",
"SELECT "
+ FacebookGraphApi.FQL_USER_SELECT
+ " FROM user WHERE uid IN (SELECT actor_id FROM #messages)");
querys.put(
"pages",
"SELECT "
+ FacebookGraphApi.FQL_PAGE_SELECT
+ " FROM page WHERE page_id IN (SELECT actor_id FROM #messages)");
Now what i would like to do is the same using RESTFB Batch Request API 现在我想使用RESTFB Batch Request API进行操作
BatchRequest firstRequest = new BatchRequestBuilder(rmtId)).build();
BatchRequest secondRequest = new BatchRequestBuilder(poster_id).build();
List<BatchResponse> batchResponses =
facebookClient.executeBatch(firstRequest,secondRequest);
These are 2 batches that executes, first one returns the post, and it contains "from", that contains poster_id of the one who posted, but i dont know how to put that poster_id from first batch to second batch so it would return poster information. 这些是执行的两个批次,第一个返回帖子,它包含“from”,其中包含发布者的poster_id,但我不知道如何将第一批中的poster_id放到第二批,以便返回海报信息。
Any help would be appreciated, thanks. 任何帮助将不胜感激,谢谢。
Just to post the answer, 只是发布答案,
first request should contain a name method on which u depend on the other request, and search on second request that depends on first ids like this. 第一个请求应该包含一个名称方法,在该方法上你依赖于另一个请求,并搜索第二个请求,这个请求依赖于这样的第一个id。
?ids={result=name-of-method:$.data.id} ?IDS = {结果=名称的-方法:$ data.id}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.