Basic SimplePie Usage

Submitted by:Jimmy Kerson

Date added:14 February, 2011

Category:PHP

You'll need a of copy Simple Pie for the include right at the top here.

Tags: simple pie , pie usage , php pie usage script

Code Snippet:

<?php
require_once('inc/simplepie.inc');

$feed = new SimplePie();

$feed->set_feed_url(array(
'http://search.twitter.com/search.atom?q=movie'
));

$feed->enable_cache(true);
$feed->set_cache_location('cache');
$feed->set_cache_duration(15);

$feed->init();

$feed->handle_content_type();

if ($feed->error): ?>

<p><?php echo $feed->error; ?></p>

<?php endif; ?>

<?php foreach ($feed->get_items() as $item): ?>

<div class="chunk">

<h4 style="background:url(<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>) no-repeat; text-indent: 25px; margin: 0 0 10px;"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4>

<p class="footnote">Source: <a href="<?php $feed = $item->get_feed(); echo $feed->get_permalink(); ?>"><?php $feed = $item->get_feed(); echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a T'); ?></p>

</div>

<?php endforeach;

?>
 
 

Comments