Ratings | | Unique User Downloads | | Download Rankings |
74% | | Total: 300 | | All time: 7,400 This week: 126 |
|
Description | | Author |
This class can parse RSS 2.0 feeds and extract all the items.
It can parse a XML RSS 2.0 file or string and parse it to extract its contents.
The class returns arrays with the list of properties of each feed item. | |
|
|
Innovation award
Nominee: 1x |
|
Example
<?php
require '../../../../vendor/autoload.php';
use bartonlp\RssFeed;
$rss = new RssFeed("testrss.xml", true, true);
$raw = escape($rss->getRawData());
echo "<pre>Raw:\n$raw";
$db = $rss->getDb();
echo "DB:\n";
var_dump($db);
$item = $rss->getItem(0);
echo "First Item:\n";
var_dump($item);
echo <<<EOF
</pre>
<p>Item title: {$item['title']}<br>
Item description: {$item['description']}</p>
EOF;
// Now iterate over the items
echo "<h1>Example of Iterating Over Entire Array of Items</h1>";
foreach($rss->getDb() as $val) {
foreach($val as $key=>$v) {
echo "$key: $v<br>";
}
echo "<hr>";
}
echo "DONE";
function escape($v) {
return preg_replace(['~<~', '~>~'], ['<', '>'], $v);
}
|
Details
RssFeed Class
This is a PHP class that can read RSS feeds.
Install
You can either clone the repository or you can use composer to install UpdateSite.
If you do not have composer you can get it at https://getcomposer.org/download/. Just follow the instruction to install it globally.
Once you have composer select a directory where you want your repository and enter:
composer require bartonlp/rssfeed:dev-master
Documentation
Documentation for RssFeed
Example
There is an example file (test.php) in the 'docs' directory along with a XML and image file that you can run.
Contact me:
bartonphillips@gmail.com
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.