Skip to content

Instantly share code, notes, and snippets.

@matiskay
Created January 2, 2012 21:03
Show Gist options
  • Save matiskay/1552110 to your computer and use it in GitHub Desktop.
Save matiskay/1552110 to your computer and use it in GitHub Desktop.
Simple Pie Example
<?php
require_once('includes/vendor/simplepie/simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url( 'your.xml' );
//$feed->set_cache_location( $_SERVER['DOCUMENT_ROOT'] . '/includes/vendor/simplepie/cache' );
//@TODO: I use my root because I'm using a simbolic link. I have to really understand whot virtualhost works.
$feed->set_cache_location( 'Set your location' );
$feed->init();
$feed->handle_content_type();
?>
foreach ($feed->get_items() as $item):
?>
<li>
<a href="<?php echo $item->get_permalink(); ?>"<?php echo $item->get_date('g:i'); ?></a>
<h2 class="text"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
</li>
endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment