Grow your CSS skills. Land your dream job.

Last updated on:

Basic SimplePie Usage

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

<?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; 
    
?>

Reference URL

Comments

  1. Matt
    Permalink to comment#

    I was playing around with this but it only loads the tweets the first time, then no further updates. I tried the workaround that SimplePie recommended, commenting out the lines of code, but it rendered the entire simplepie.inc file useless.

    Were you able to get this to work?

  2. Fadil
    Permalink to comment#

    Now SimplePie uses an autoloader.php instead of simplepie.inc.

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like this:

```
<div>Example code</div>
```

You don't need to escape code in backticks, Markdown does that for you. If anything screws up, contact us and we can fix it up for you.

*May or may not contain any actual "CSS" or "Tricks".