tomaj / feed-downloader
Simple feed downloader.
1.0.0
2014-09-03 11:37 UTC
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: 4.2.*
- satooshi/php-coveralls: dev-master
- squizlabs/php_codesniffer: ~1.5
This package is not auto-updated.
Last update: 2024-12-17 03:35:43 UTC
README
Simple library for downloading various feed.
Requirements
Feed downloader requires PHP 5.3.0 or higher.
Instalation
The best way to install feed-downloader is using Composer:
$ composer require tomaj/feed-downloader
Usage
You can use feed-downloader to download rss and process data with your function
$downloader = new \Tomaj\FeedDownloader\Downloader\CurlDownloader(); $processor = new \Tomaj\FeedDownloader\Processor($downloader); $url = 'http://somerssfeed.xml'; $result = $processor->processFeed($url, new \Tomaj\FeedDownloader\Parser\RssParser(), function(\Tomaj\FeedDownloader\FeedItem $item) { // custom handling $item echo $item->getTitle() . "\n"; echo $item->getLink() . "\n"; echo $item->getDescription() . "\n"; echo $item->getGuid() . "\n"; echo $item->getPubDate() . "\n"; }); if ($result === \Tomaj\FeedDownloader\Processor::PARSE_ERROR) { // error in xml } elseif ($result === \Tomaj\FeedDownloader\Processor::DOWNLOAD_ERROR) { // error with downloading }
Todo
- Encodings conversions
- DateTime in FeedItem
- Unify url/link with one getter
- Change ungly parser with multiple ifset() methods
- CurlDownloader test
Repository http://github.com/tomaj/feed-downloader.