我正在尝试从Facebook页面获取所有帖子和评论。
到目前为止,使用以下FQL效果很好:
{'all_posts':
'SELECT created_time, post_id, actor_id, message, description, comments FROM stream
WHERE source_id=PAGE_ID ORDER BY created_time',
'comments':
'SELECT id, fromid, post_fbid, text, time, post_id FROM comment WHERE post_id
IN (SELECT post_id FROM #all_posts) ORDER BY post_id'
}
我正在尝试使用RestFB库,但是我得到了
com.restfb.exception.FacebookResponseStatusException: Received Facebook error response
(code 601): Parser error: unexpected '{' at position 0.
当我尝试执行查询时:
List<JsonObject> queryResults = facebookClient.executeQuery(query, JsonObject.class);
我该如何解决这个问题?
提前致谢。
最佳答案
我认为这是RestFB方面的一个错误,它解析结果json,因为我遇到了几个异常并且有点困惑。
正确的方法是使用RestFB(Executing Multiqueries with RestFb)的多查询支持
Map<String, String> queries = new HashMap<String, String>();
queries.put("all_posts", "select created_time, post_id, actor_id, message, description, comments from stream where source_id=279947942083512 ORDER BY created_time");
queries.put("comments", "SELECT fromid, username, text, time, post_id FROM comment WHERE post_id in (SELECT post_id FROM #all_posts) ORDER BY post_id");
MultiqueryResults queryResults = facebookClient.executeMultiquery(queries, MultiqueryResults.class);
您必须提供1中所述的MultiqueryResults Bean