I'm trying to fetch all the posts and comments from a Facebook Page. This works quite good so far using the following 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'
}
I'm trying to use the RestFB Library, but I get
com.restfb.exception.FacebookResponseStatusException: Received Facebook error response
(code 601): Parser error: unexpected '{' at position 0.
when I try to execute the query:
List<JsonObject> queryResults = facebookClient.executeQuery(query, JsonObject.class);
How can I solve this issue?
Thanks in advance.
I thought it was a mistake on RestFB side, parsing the result json, because I got several Exceptions and was kind of confused.
The right way to do this is to use the Multiquery Support of 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);
You have to provide the MultiqueryResults Bean as described in 1