AggragateRSS.php

 1: <?php
 2: // This PHP script wil read a list of (local) RSS feeds
 3: // and produce a single aggragate output feed.  This allows
 4: // me to have one feed per course, and a site-wide feed
 5: // automatically generated.
 6: // All local feeds have the name "*RSS.xml" but the number is
 7: // small enough to maintain the list by hand in the file
 8: // "RSS-feeds.txt" (one filename per line), which speeds up the
 9: // script by avoiding a directory search of the whole site for
10: // feed files.
11: //
12: 
13: define('MAGPIE_DIR', './');
14: require_once(MAGPIE_DIR . 'rss_parse.inc');
15: 
16: $rss_file = 'Cts2322RSS.xml';
17: //$rss_file = 'RSS-feeds.txt';
18: $rss_string = file_get_contents($rss_file);
19: $rss = new MagpieRSS( $rss_string );
20: 
21: //var_dump($rss);
22: echo "<hr>";
23: 
24: if ( $rss and !$rss->ERROR) {
25:   echo "Channel Title: " . $rss->channel['title'] . "<p>";
26:   echo "<ul>";
27:   foreach ($rss->items as $item)
28:   {
29:     $href = $rss->channel['link']; // $item['link'];
30:     $title = $item['title'];
31:     echo "<li><a href=$href>$title</a></li>";
32:   }
33:   echo "</ul>";
34: }
35: else {
36:     echo "Error: " . $rss->ERROR;
37: }
38: 
39: ?>