sgvsv / php-yandex-zen-rss-feed
生成支持 Yandex Zen 格式的 RSS 源
v1.3
2022-08-01 14:29 UTC
Requires
- php: >=7.1
- ext-fileinfo: *
- ext-libxml: *
- ext-simplexml: *
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-08-29 05:18:26 UTC
README
简单的 PHP 类,用于生成 Yandex Zen 格式的 RSS 源
需求
为了提供现代 PHP 功能,例如在方法签名中设置类型,需要 PHP7.1 或更高版本。同时,您还需要一些扩展
- ext-fileinfo
- ext-libxml
- ext-simplexml
如果您想运行测试,需要 phpunit 7.5 或更高版本
安装
使用此库的最佳方式是通过 composer 安装
composer require sgvsv/php-yandex-zen-rss-feed
使用示例
安装后,您可以创建 RSS 源
require_once __DIR__.'/vendor/autoload.php'; //New feed with global parameters in constructor $feed = new \sgvsv\Yandex\Zen\Feed('My feeds title', 'Description text here', 'https://mysite.com', 'https:/mysite.com/rss.xml'); //News 1 item $item = $feed->newItem(); $item->title = "News 1"; $item->link = "https://mysite.com/news/1"; $item->pubDate = "Fri, 12 Aug 2013 15:52:01 +0000"; $item->author = 'editor@mysite.com (my site)'; $item->category = 'software'; $item->description = "Description's text"; $item->content = "Content of my news"; $item->addImage("https://mysite.com/images/news1.jpg", "Image's description", "1234"); //Set HTTP header $feed->setHTTPHeader(); //Output Feed echo $feed->getXML();