desarrolla2 / rss-client
v2.2.1
2013-12-04 09:19 UTC
Requires
- php: >=5.3.0
- desarrolla2/cache: 1.*
- ezyang/htmlpurifier: 4.5.*
- guzzle/guzzle: 3.*
Requires (Dev)
- raulfraile/ladybug: ~1.0
README
RSSClient 将不再更新,您应考虑迁移到 FastFeed https://github.com/FastFeed/FastFeed
RSSClient
RSSClient 是一个简单的 RSS 库,用于获取和使用 RSS 源。RSSClient 非常快!
支持的格式
安装
通过 Composer
最好通过在您的项目 composer.json require 中包含 desarrolla2/rss-client
来通过 packagist 安装。
"require": { // ... "desarrolla2/rss-client": "dev-master" }
不通过 Composer
您还可以从 [Github] (https://github.com/desarrolla2/RSSClient) 下载它,但未提供自动加载器,因此您需要使用自己的 PSR-0 兼容自动加载器注册它。
使用方法
不使用缓存
此示例不使用任何缓存,因此可能太慢而不能在网站上使用,您应该实现自己的系统缓存或使用以下描述的缓存系统。
<?php use Desarrolla2\RSSClient\RSSClient; $client = new RSSClient(); $client->addFeeds( array( 'http://news.ycombinator.com/rss', 'http://feeds.feedburner.com/TechCrunch/', ), 'news' ); $feeds = $client->fetch('news');
使用缓存
此示例使用 desarrolla2/cache
实现的缓存,您必须根据需要选择适配器,您可以在 [Github 仓库] (https://github.com/desarrolla2/Cache) 中找到所有信息。
<?php // It is important that you select and configure your cache adapter $client = new RSSClient(); $client->setCache(new Cache(new File('/tmp')));
您可以在其 [README] (https://github.com/desarrolla2/Cache) 中看到如何配置 desarrolla2/cache。
其余步骤与使用无缓存客户端完全相同。
<?php $client->addFeeds( array( 'http://news.ycombinator.com/rss', 'http://feeds.feedburner.com/TechCrunch/', ), 'news' ); $feeds = $client->fetch('news');
限制元素数量
您可以使用 fetch
方法的第二个参数来限制元素数量。
<?php $feeds = $client->fetch('news', 20);
其他
联系方式
您可以在 twitter 上联系我。