Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Extract RSS feeds with PHP

Friday, January 25th, 2013 by Servage

It’s very easy to fetch RSS feeds with PHP and use them on your website, if you wish. This could be useful to aggregate information or news from relevant sources, or if you for some other reason need to import or display data which you have available as a feed, SimplePie is a PHP library which provides this support through an easy framework which allows you to extract data in an object oriented way. Nice and easy.

Example how to start SimplePie and fetch a feed

// Instantiate SimplePie
$feed = new SimplePie();

// Define which URL to load the feed from

// Initialize the feed

Use information from the feed

// You can get various meta data from the feed
echo $feed->get_permalink();
echo $feed->get_title();
echo $feed->get_description();

Use feed items

// Go through each item and display information for them
foreach ($feed->get_items() as $item) {
	echo $item->get_title();
	echo $item->get_permalink();
	echo $item->get_description();
	echo $item->get_date('j F Y | g:i a');

This should get you started to use feeds in your project :-)

Extract RSS feeds with PHP, 3.7 out of 5 based on 3 ratings
Categories: Software & Webapps

Keywords: ,

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.