All pastes #919423 Raw Edit

Untitled

public php v1 · immutable
#919423 ·published 2008-02-26 20:24 UTC
rendered paste body
<?php// Include the SimplePie libraryinclude_once('../simplepie.inc');// Initialize a specific feed. ALL configuration options need to be set BEFORE calling init(), or else they will be IGNORED.// In the case of the original code, they didn't do anything to help you, so let's start simple then work our way up once it all works.$feed = new SimplePie();$feed->set_feed_url('http://bear.politicalbear.com/feed');$feed->enable_cache(false);// Do not strip out <object>, <param>, and <embed> tags$strip_htmltags = $feed->strip_htmltags;unset($strip_htmltags[array_search('object', $strip_htmltags)]);unset($strip_htmltags[array_search('param', $strip_htmltags)]);unset($strip_htmltags[array_search('embed', $strip_htmltags)]);$strip_htmltags = array_values($strip_htmltags);$feed->strip_htmltags($strip_htmltags);// If processing the feed was successful, this will return true.$success = $feed->init();// Have SimplePie set the HTTP headers.// Stop what you're doing and read http://ref.simplepie.org/handle_content_type to learn when you should/shouldn't use this.$feed->handle_content_type();?><div class="style8" id="sp_results">	<?php	// As long as the feed has data to work with...	if ($success):	?>		<?php echo '<a href="' . $feed->get_permalink() . '">' . $feed->get_title() . '</a>'; ?><br />		<?php echo $feed->get_description(); ?>		<?php		// It's a little silly to use PHP's foreach construct for only a single item.		foreach ($feed->get_items(0,1) as $item):		?>			<div align="center">				<h4><?php echo '<a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a>'; ?></h4>			</div>			<?php			// Display the item's primary content.			echo $item->get_content();			?>			<!-- Add links to add this post to one of a handful of services. -->			<p class="footnote favicons" align="center">				<a href="<?php echo $item->add_to_blinklist(); ?>" title="Add post to Blinklist"><img src="Images/favicons/blinklist.png" alt="Blinklist" /></a>				<a href="<?php echo $item->add_to_blogmarks(); ?>" title="Add post to Blogmarks"><img src="Images/favicons/blogmarks.png" alt="Blogmarks" /></a>				<a href="<?php echo $item->add_to_delicious(); ?>" title="Add post to del.icio.us"><img src="Images/favicons/delicious.png" alt="del.icio.us" /></a>				<a href="<?php echo $item->add_to_digg(); ?>" title="Digg this!"><img src="Images/favicons/digg.png" alt="Digg" /></a>				<a href="<?php echo $item->add_to_magnolia(); ?>" title="Add post to Ma.gnolia"><img src="Images/favicons/magnolia.png" alt="Ma.gnolia" /></a>				<a href="<?php echo $item->add_to_myweb20(); ?>" title="Add post to My Web 2.0"><img src="Images/favicons/myweb2.png" alt="My Web 2.0" /></a>				<a href="<?php echo $item->add_to_newsvine(); ?>" title="Add post to Newsvine"><img src="Images/favicons/newsvine.png" alt="Newsvine" /></a>				<a href="<?php echo $item->add_to_reddit(); ?>" title="Add post to Reddit"><img src="Images/favicons/reddit.png" alt="Reddit" /></a>				<a href="<?php echo $item->add_to_segnalo(); ?>" title="Add post to Segnalo"><img src="Images/favicons/segnalo.png" alt="Segnalo" /></a>				<a href="<?php echo $item->add_to_simpy(); ?>" title="Add post to Simpy"><img src="Images/favicons/simpy.png" alt="Simpy" /></a>				<a href="<?php echo $item->add_to_spurl(); ?>" title="Add post to Spurl"><img src="Images/favicons/spurl.png" alt="Spurl" /></a>				<a href="<?php echo $item->add_to_wists(); ?>" title="Add post to Wists"><img src="Images/favicons/wists.png" alt="Wists" /></a>				<a href="<?php echo $item->search_technorati(); ?>" title="Who's linking to this post?"><img src="Images/favicons/technorati.png" alt="Technorati" /></a>						</p>			</p>		<?php		// Stop looping through each item once we've gone through all of them.		endforeach;		?>	<?php	// From here on, we're no longer using data from the feed.	endif;	?></div>