我想閱讀使用facebook4j庫的帖子的facebook評論。它只返回帖子,但不返回該帖子的評論。即使在任何帖子中有更多評論,它總是回覆空白。任何人都可以引導我以正確的方式從特定的帖子獲取所有評論嗎?無法閱讀使用facebook4j的Facebook評論
import facebook4j.Comment;
import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.PagableList;
import facebook4j.Post;
import facebook4j.Reading;
import facebook4j.ResponseList;
import facebook4j.auth.AccessToken;
public class PostsFromPageExtractor {
/**
* A simple Facebook4J client which
* illustrates how to access group feeds/posts/comments.
*
* @param args
* @throws FacebookException
*/
public static void main(String[] args) throws FacebookException {
// Generate facebook instance.
Facebook facebook = new FacebookFactory().getInstance();
// Use default values for oauth app id.
facebook.setOAuthAppId("", "");
// Get an access token from:
// https://developers.facebook.com/tools/explorer
// Copy and paste it below.
String accessTokenString = "PASTE_YOUR_ACCESS_TOKEN_HERE";
AccessToken at = new AccessToken(accessTokenString);
// Set access token.
facebook.setOAuthAccessToken(at);
// We're done.
// Access group feeds.
// You can get the group ID from:
// https://developers.facebook.com/tools/explorer
// Set limit to 25 feeds.
ResponseList<Post> feeds = facebook.getFeed("187446750783",new Reading().limit(25));
// For all 25 feeds...
for (int i = 0; i < feeds.size(); i++) {
// Get post.
Post post = feeds.get(i);
// Get (string) message.
String message = post.getMessage();
// Print out the message.
System.out.println(message);
// Get more stuff...
PagableList<Comment> comments = post.getComments();
String date = post.getCreatedTime().toString();
String name = post.getFrom().getName();
String id = post.getId();
}
}
}
String name = "pagename";
ResponseList<Post> feeds = facebook.getFeed(name, new Reading().limit(250));
System.out.println(feeds.size());
我也遇到過這種錯誤..你能夠得到與獲得的object_id的數據? –
呀。我可以得到一個帖子。但不包含任何評論。原因是什麼? –
我們在同一條船上! –