在建站五年后,终于是把这个古老的RSS订阅功能做了支持。。。
在建站五年后,终于是把这个古老的RSS订阅功能做了支持。。。
https://www.baby7blog.com/feed


在Win下比较方便的就是使用Fluent Reader进行订阅(在设置出添加上方的链接地址为订阅源即可)

用了一个rss的包,build.gradle:
1 2
| implementation 'com.rometools:rome:1.8.0'
|
然后是脱敏后的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| private String getRss() throws FeedException { Channel channel = new Channel(); channel.setEncoding("Utf-8"); channel.setFeedType("rss_2.0"); channel.setTitle("博客标题"); channel.setLink("rss订阅地址"); channel.setDescription("博客简介"); channel.setLanguage("zh-cn"); channel.setCopyright("Copyright信息"); channel.setManagingEditor("邮箱(博主)"); channel.setWebMaster("邮箱(博主)"); channel.setUri("博客地址"); channel.setGenerator("由谁构建");
Image image = new Image(); image.setUrl("图标地址"); image.setTitle("博客标题"); image.setHeight(32); image.setWidth(32); channel.setImage(image);
Date lastDate = new Date(0L); List<Blog> blogList = xxxxx.list(); List<Item> itemList = new ArrayList<>(); for(Blog blog : blogList){ Item item = new Item(); item.setAuthor("博主"); item.setLink("博文地址"); item.setTitle("博文标题"); item.setUri("博文地址"); item.setComments("博文地址"); Date date = XXX; com.rometools.rome.feed.rss.Category category = new com.rometools.rome.feed.rss.Category(); category.setValue("分类"); item.setCategories(Collections.singletonList(category)); Description desc = new Description(); desc.setValue("博文XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); item.setDescription(desc); item.setPubDate(date); itemList.add(item); if(lastDate.before(date)){ lastDate = date; } } channel.setItems(itemList); channel.setLastBuildDate(lastDate); WireFeedOutput output = new WireFeedOutput(); return output.outputString(channel); }
|
此为博主副博客,留言请去主博客,转载请注明出处:https://www.baby7blog.com/myBlog/141.html