我有这段代码可以使用 Blogger Java API 读取提要中的帖子
public static void printAllPosts(
GoogleService myService, String blogId)
throws ServiceException, IOException {
// Request the feed
URL feedUrl = new URL("http://www.blogger.com/feeds/" + blogId + "/posts/default");
Feed resultFeed = myService.getFeed(feedUrl, Feed.class);
System.out.println("Number of posts: "+resultFeed.getEntries().size());
// Print the results
//System.out.println(resultFeed.getTitle().getPlainText());
/*for (int i = 0; i < resultFeed.getEntries().size(); i++) {
Entry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getTitle().getPlainText());
}*/
System.out.println();
}
在这种特定情况下,我只是打印库正在获取多少帖子,并且输出始终为
Number of posts: 25
虽然我的博客上有 800 个帖子。
为什么它只获取最新的 25 篇文章?我缺少什么?我怎样才能让它阅读所有帖子?
最佳答案
替换这个
URL feedUrl = new URL("http://www.blogger.com/feeds/" + blogId + "/posts/default");
与
URL feedUrl = new URL("http://www.blogger.com/feeds/" + blogId + "/posts/default?redirect=false&start-index=1&max-results=500");
限制大多为 499 或 500 不过,你可以尝试在行中输入 800,希望也能奏效:)
关于java - Blogger java api 仅读取最后 25 篇文章,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16754311/