Using Magpie RSS

December 12th, 2005 by Sarah King

Magpie RSS is an RSS parser available free from SourceForge.

It consists of a handful of scripts which sit on your site and creates a cache file which needs to be chmod'd to 755 or 777 - you may need to use your FTP tool to do that - or Magpie may do it for you.

So, what do you need to do?

  1. Visit the Magpie site and download the latest version of the files.
  2. Unzip the files on your local file system. They come with some examples which may be good to have a play with, but you actually only need to upload these into a "magpie" directory
    • rss_cache.inc
    • rss_fetch.inc
    • rss_parse.inc
    • rss_utils.inc
    • extlib/Snoopy.class.inc
  3. Now, decide which page you want to add the feed to and open the appropriate file in your favourite editor (mine is Zend).
  4. Now you just have to add these lines to the file, save and upload!
    PHP:
    1. define('MAGPIE_DIR', 'magpie/');
    2. require_once(MAGPIE_DIR.'rss_fetch.inc');
    3.  
    4. $rss = fetch_rss( 'http://www.propertyinvestor.info/articles/feed/' );
    5. $items = array_slice($rss->items, 0, 5);
    6.  
    7. $output = "<table cellspacing='0' cellpadding='0'>
    8. <tr><th valign='top'><a href='{$rss->channel['link']}'>{$rss->channel['title']}</a> - {$rss->channel['description']}</th></tr>";
    9. foreach ($items as $item)
    10. {
    11.     $output .= "<tr><td><a href='{$item['link']}' title=\"$item['title']\">{$item['title']}</a></td></tr>";
    12. }
    13. echo '</table>'.$output;

To be completed...

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Twitter
  • StumbleUpon
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Add to favorites
  • Sphinn
  • NewsVine
  • Propeller
  • Yahoo! Bookmarks
  • Yahoo! Buzz

2 Responses to “Using Magpie RSS”

  1. That cookbook didnt get it working for me atleast.

    What did I do wrong:

    http://www.finna.no/rss.php

  2. Hannah says:

    Think line 11 may be incorrect. Replace it with

    $output .= “{$item['title']}“;

    There was a pair of curly braces missing on one of items. Got it working for me.

Leave a Reply

You must be logged in to post a comment.