All pastes #919086 Raw Edit

Untitled

public php v1 · immutable
#919086 ·published 2008-02-26 16:14 UTC
rendered paste body
<?php// Include the core SimplePie library.require_once('../simplepie.inc');// Manually set the page's HTTP headers to HTML and UTF-8. See http://php.net/header for more details on when and when not to use this.header('Content-type:text/html; charset=utf-8');// Create a function that will do the same thing over and over again.function display_feed($feed_url){	// Initialize a new SimplePie instance, and tell it to use the Apple.com feed.	$feed = new SimplePie();	$feed->set_feed_url($feed_url);	// Tell SimplePie we're done setting options, we're ready to process, and use an "if" condition to ensure it was successful.	if ($feed->init())	{		// Display the feed header.		echo '<h3><a href="' . $feed->get_permalink() . '">' . $feed->get_title() . '</a></h3>';		// Begin our list tag		echo '<ul>';		// Starting at the first item (item 0), and pulling the following 5 items, loop through them one by one.		foreach ($feed->get_items(0,5) as $item)		{			// Display these item titles as list items.			echo '<li><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></li>';		}		// End our list tag.		echo '</ul>';	}	// If the feed did not process successfully...	else	{		// Kill the script, and display SimplePie's error message.		die($feed->error());	}}///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Call the function for each feed you want to display.display_feed('http://images.apple.com/main/rss/hotnews/hotnews.rss');display_feed('http://digg.com/rss/containertechnology.xml');display_feed('http://feeds.tuaw.com/weblogsinc/tuaw');?>