All pastes #919078 Raw Edit

Sample 3 feed display with Simpl

public php v1 · immutable
#919078 ·published 2008-02-26 16:09 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');// Initialize a new SimplePie instance, and tell it to use the Apple.com feed.$apple = new SimplePie();$apple->set_feed_url('http://images.apple.com/main/rss/hotnews/hotnews.rss');// Tell SimplePie we're done setting options, we're ready to process, and use an "if" condition to ensure it was successful.if ($apple->init()){	// Display the feed header.	echo '<h3><a href="' . $apple->get_permalink() . '">' . $apple->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 ($apple->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($apple->error());}///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Do it all over again with a new feed.$digg = new SimplePie();$digg->set_feed_url('http://digg.com/rss/containertechnology.xml');if ($digg->init()){	echo '<h3><a href="' . $digg->get_permalink() . '">' . $digg->get_title() . '</a></h3>';	echo '<ul>';	foreach ($digg->get_items(0,5) as $item)	{		echo '<li><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></li>';	}	echo '</ul>';}else{	die($digg->error());}///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Do it all over again with a new feed.$tuaw = new SimplePie();$tuaw->set_feed_url('http://feeds.tuaw.com/weblogsinc/tuaw');if ($tuaw->init()){	echo '<h3><a href="' . $tuaw->get_permalink() . '">' . $tuaw->get_title() . '</a></h3>';	echo '<ul>';	foreach ($tuaw->get_items(0,5) as $item)	{		echo '<li><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></li>';	}	echo '</ul>';}else{	die($tuaw->error());}?>