Magpie RSS display using PHP

Magpie allows you to save an external RSS file (in a cache) and display the results on your page, using PHP.

You need to copy the files to the server (including scripts & extlib), and create a cache directory (same level as the calling page). Set the cache to the same group as the server and chmod it to 775. Then the following should work (created using Magpie 0.71), just replace your.feed.


define('MAGPIE_DIR', 'rss/');
if ( isset($_GET['url']) ) {
	$url = $_GET['url'];
else {
	$url = 'http://your.feed';
$num_items = 8;
$rss = fetch_rss( $url );
$items = array_slice($rss->items, 0, $num_items);
if ($rss) {
	echo "<ul class=\"alignleft faves\">";
	echo "<li><h3>Latest reads</h3></li>";
	foreach ($items as $item) {
		$href = $item['link'];
		$title = $item['title'];	
		echo "<li><a href=$href>$title</a></li>";
	echo "</ul>";
else {
	echo "Error: " . magpie_error();

2 contributions to “Magpie RSS display using PHP

  1. Cheers Mate, am trying to add a weather report RSS to my website I will let you know if it works for the latest magpir version.

Leave a Reply

Your email address will not be published. Required fields are marked *