[php] 将多个 RSS 地址合并成一个

弄了个 php 程序,可以把自己的(or 别人的)多个 blog 的 RSS 订阅地址,合并成一个,供人订阅。例如,现在本站的几个 blog 的统一订阅地址为:

https://feed.fivest.one/

程序基于 DigitalFreelancing 的代码,略作修改,调用了 SimplePie 处理 RSS 的项目库,为每个原始的 RSS 地址生成缓存,避免了频繁读取。我修改后的版本,可以从【这里】下载。

使用说明

  • 配置支持 PHP 的网络服务器,过程略;
  • 下载源文件后,解压到新的 RSS 地址相应的文件夹里;
  • 编辑 index.php,修改如下部分:
$feedlink = "https://feed.fivest.one/"; // 这个新的 RSS 的网址
$feedtitle = "fivestone"; // RSS 名称
$feedhome = "https://fivest.one"; // 你的网站地址(在 RSS 阅读器里点击 Title 可以进入)
$feeddesc = "fivestone's posts aggregation"; // RSS 描述

$feeds = array( // 需要合并的 RSS 网址列表,以引号和逗号分隔
    'https://a.fivest.one/feed',
    'https://b.fivest.one/feed'
);

$time_zone = 'Asia/Taipei'; // RSS 使用的时区
$item_number_limit = 20; // 新的 RSS 显示的文章数上限
$creativeCommons_license = 'https://creativecommons.org/licenses/by-sa/4.0'; // 你选择的知识产权协议(可以自行修改或为空)
  • 根据你的网络服务器的权限配置方式,可能需要把 cache 文件夹设为群组或全部可写
chmod g+w cache 或者 chmod a+w cache
  • 也可以把 index.php 改名,或者复制到其它位置,分别配置,生成多个这样的聚合 RSS。注意要调整文件中的相对路径:
include_once('./simplepie/autoloader.php');

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.