qrss
1.0.0
An API Class to parse the RSS feed into json with cache option.
Grab the qrss
class and use require it in your php file.
require 'src/qrss.php';
// To fetch an RSS feed as json use
(new qrss('https://news.google.com/?output=rss'))->json();
// For fresh copy you can use fresh() which will ignore cache
(new qrss('https://news.google.com/?output=rss'))->fresh()->json()
// Get the feed ignoring validation adding novalidate()
(new qrss('https://en.blog.wordpress.com/feed/'))->novalidate()->json();
// There is also an option to get data in plain text using text() instead of json()
(new qrss('https://news.google.com/?output=rss'))->text();
You can also extend the parse method to customize the output.
class Myqrss extends qrss {
protected function parse($xml)
{
// you have all the xml elements as SimpleXMLElement object
// parse it however you want, return the array from this
return [
'title' => (string) $xml->channel->title
];
}
}
(new Myqrss('https://news.google.com/?output=rss'))->json();