tomaj/feed-downloader

Simple feed downloader.

1.0.0 2014-09-03 11:37 UTC

This package is not auto-updated.

Last update: 2024-11-05 03:03:46 UTC


README

Build Status Code Climate Test Coverage

Latest Stable Version Latest Unstable Version License

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.