我正在编写一个servlet,我想在其中读取Wordpress提要。如何从wordpress提要中获取帖子/页面的数量?是否有URL参数?
假设每个页面都有固定的帖子数量(在我的例子中是6)
发布于 2011-07-15 06:50:53
Wordpress提要使用RSS,因此您需要使用Java RSS库。
问题(和答案)在这里:java library for reading RSS and ATOM feeds
答案,引用:
尽管它已经被提到过几次,我还是建议使用Rome。
更新: Wordpress也有一个XmlRpc应用程序接口,所以你可以用它来查询帖子。我所能看到的最接近于获得帖子/页面数量的方法是使用wp.getPageList,它返回一个包含所有帖子和最少数据的数组。
作为XmlRpc API支持的一部分,Wordpress实现了几个标准,包括Blogger API,其中有一个decent tutorial。同样,没有特定的'getPostCount()‘函数。
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);
// 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();
}https://stackoverflow.com/questions/6697107
复制相似问题