1

我正在尝试从 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);

我该如何解决这个问题?

提前致谢。

4

1 回答 1

0

我认为这是 RestFB 方面的错误,解析结果 json,因为我得到了几个异常并且有点困惑。

正确的方法是使用 RestFB 的 Multiquery Support ( 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);

您必须提供 MultiqueryResults Bean,如1中所述

于 2013-02-13T16:53:22.820 回答