mehedimi / feed-reader
A package for reading rss or atom feed
1.0
2020-06-02 12:18 UTC
Requires
- php: >=5.6
- ext-curl: *
- ext-json: *
- ext-simplexml: *
Requires (Dev)
- phpunit/phpunit: ^8.5
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2024-12-08 22:57:30 UTC
README
A simple feed reader
Installation
$ composer require mehedimi/feed-reader
Basic Uses:
<?php $feed = new \Mehedi\Feed(); // Reading RSS Feed $rss = $feed->rss('http://your-url.com/rss') ->read(); echo $rss->getTitle(); // Get the channel title // Access channel extra field echo $rss->channel()->extra; foreach ($rss->items() as $item) { echo $item->title; // Get the item title // Accessing attribute echo $item->title->attributes()->attributeName; } // Reading Atom Feed $atom = $feed->atom('http://your-url.com/atom') ->read(); echo $atom->getTitle(); // Title echo $atom->getUpdated()->format('d F, Y'); // Last Updated Date // Access channel extra field echo $atom->feed()->extra; foreach ($atom->entries() as $entry) { echo $entry->title; // Get the item title // Accessing attribute echo $entry->title->attributes()->attributeName; }
Authentication
If your feed resource are protected by HTTP Basic Auth then you can use basicAuth
<?php $feed = new \Mehedi\Feed(); $feed->rss('url') ->basicAuth('username', 'password') ->read(); // OR $feed->atom('url') ->basicAuth('username', 'password') ->read();
With Laravel
<?php // Just use Feed Facade $rss = \Mehedi\Facades\Feed::rss('url')->read();