topical media & game development

talk show tell print

professional-search-07-seophp-read-feed.php / php



  <?php
  // load the SimplePie library
  require_once 'include/simplepie.inc';
  
  // create and configure SimplePie object
  feed = new SimplePie();
  feed->feed_url('http://seophp.example.com/feed.php');
  feed->cache_location('cache');
  feed->init();
  feed->handle_content_type();
  ?>
  
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  <html>
  <head>
    <title>Feed Reading Test</title>
  </head>
  <body>
  
  <?php 
  if (feed->data) 
  { 
    // display the title
    echo '<h1>' . 
           '<a href="' . feed->get_feed_link() . '">' .
             feed->get_feed_title() . 
           '</a>' .
         '</h1>';
  
    // display a maximum of 5 feed items
    max = feed->get_item_quantity(5);
    for (x=0; x<max; x++) 
    {
      item = feed->get_item(x);
  
      // display feed link and title
      echo '<h2>' . 
             '<a href="' . item->get_permalink() . '">' .
               item->get_title() . 
             '</a>' . 
           '</h2>';
  
      // display feed description
      echo '<p>' . item->get_description() . '</p>';
    }
  }
  ?>
  
  </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.