Professional Freelance Web Developer
CodeIgniter Activist, Caffeine Junkie

Elliot Haughin

SimplePie CodeIgniter Library

SimplePieParsing RSS feeds with PHP has always been a bit of a pain the ass.
But, SimplePie makes it much simpler!

In your controllers, simply load the library, set your feed url.. and you’re away!

$this->load->library('simplepie');
$this->simplepie->set_feed_url('http://feeds.haughin.com/haughin');
$this->simplepie->set_cache_location(APPPATH.'cache/rss');
$this->simplepie->init();
$this->simplepie->handle_content_type();
 
$data['rss_items'] = $this->simplepie->get_items();

Then, to use the feed data:

echo "<li>";
foreach($rss_items as $item) {
	echo "<li>";
	echo "<a href='" .$item->get_link() . "'>";
	echo $item->get_title();
	echo "</a>";
	echo "</li>";
}
echo "</li>";

You can pretty much use the data how you like… check out the simplepie documentation to see all of the data you can get from a feed.

Download Simplepie CodeIgniter Library

Version: 1.0

Boring Stuff

Design © copyright Elliot Haughin 2009

Content published here are copyright their respective owners.

You cannot copy content from this site, either in English or translated to another language.

Keep Subscribed

Theres lots of ways for you to keep up with me on the web.

Please Note

Information given out on this blog should only be used as a guideline. I hold no liability for any code I write.

Always consult a professional before acting on this guidance.