Code:
<?php
//Function for ouputting the body of each RSS item displayed (inside loop)- DynamicDrive.com
require('../simplepie/simplepie.inc'); //Specify path to simplepie.inc on your server (by default located inside "simplepie" directory)
$feed = new SimplePie();
$feed->cache_location('cache'); //Specify path to cache directory on your server relative to this file
$feed->handle_content_type();
require('outputbody.php'); //Path to custom "outputbody.php" file relative to this file
//Specify list of RSS URLs
$rsslist=array(
"reutersW" =>"http://feeds.reuters.com/reuters/worldNews",
"googleW" => "http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=w&output=rss",
"bbcW" => "http://feeds.bbci.co.uk/news/world/rss.xml",
"usatodayW" => "http://content.usatoday.com/marketing/rss/rsstrans.aspx?feedId=news4",
"foxnewsW" => "http://feeds.foxnews.com/foxnews/world",
"yahooW" => "http://rss.news.yahoo.com/rss/world",
"msnbcW" =>"http://rss.msnbc.msn.com/id/3032506/device/rss/rss.xml",
"nytimesW" =>"http://www.nytimes.com/services/xml/rss/nyt/World.xml",
"postW" => "http://www.nypost.com/rss/international.xml",
"cnnW" => "http://rss.cnn.com/rss/cnn_world.rss",
"bingW" =>"http://api.bing.com/rss.aspx?Source=News&Market=en-US&Version=2.0&News.Category=rt_World&Query=",
"forbesW" =>"http://www.forbes.com/news/index.xml",
"cbsUS" =>"http://www.cbsnews.com/feeds/rss/national.rss",
"dailynewsUS" =>"http://www.nydailynews.com/news/us_world/index_rss.xml",
"bingUS" =>"http://api.bing.com/rss.aspx?Source=News&Market=en-US&Version=2.0&News.Category=rt_US&Query=",
"cnnUS" =>"http://rss.cnn.com/rss/cnn_us.rss",
"reutersUS" =>"http://feeds.reuters.com/Reuters/domesticNews",
"googleUS" =>"http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=n&output=rss",
"bbcUS" =>"http://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml",
"usatodayUS" => "http://content.usatoday.com/marketing/rss/rsstrans.aspx?feedId=news2",
"foxnewsUS" =>"http://feeds.foxnews.com/foxnews/us",
"yahooUS" =>"http://us.lrd.yahoo.com/_ylt=AmTWd6a9o9z.og8m4kqwSvVvzwcF;_ylu=X3oDMTB2aTFkMG5lBHBvcwMzBHNlYwN5bl9wcm9tb3NfcnNzBHNsawNyc3M-/SIG=1155jnqjm/**http%3A//rss.news.yahoo.com/rss/us",
"msnbcUS" =>"http://www.msnbc.msn.com/id/5216556/#U.S.News",
"timesUS" =>"http://www.nytimes.com/services/xml/rss/nyt/US.xml",
"postUS"=> "http://www.nypost.com/rss/nationalnews.xml",
"goobusB" => "http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=b&output=rss",
"cnnmoneyB" => "http://rss.cnn.com/rss/money_topstories.rss",
"usmoneyB" =>"http://rssfeeds.usatoday.com/UsatodaycomMoney-TopStories",
"forbesB" =>"http://www.forbes.com/business/index.xml",
"foxmoneyB" =>"http://feeds.foxbusiness.com/foxbusiness/latest",
"yafinB"=>"http://finance.yahoo.com/rss/techticker;_ylt=AhZ4gT.gwOd5qsK81YonnTxk7ot4;_ylu=X3oDMTBuazEwM2JsBHBvcwM2BHNlYwN0dE5hdgRzbGsDcnNz",
"forbesB" =>"http://www.forbes.com/business/index.xml",
"dailyfiB" =>"http://www.dailyfinance.com/rss.xml",
"ftB" =>"http://www.ft.com/rss/home/us",
"busweekB" =>"http://www.businessweek.com/rss/technology.rss",
"technewsT" =>"http://www.technewsworld.com/perl/syndication/rssfull.pl",
"cnetT" =>"http://news.cnet.com/2547-1_3-0-20.xml",
"pcmagT" =>"XMLhttp://rssnewsapps.ziffdavis.com/pcmagbreakingnews.xml",
"forbesT" =>"http://www.forbes.com/technology/index.xml",
"popsciT" => "http://www.popsci.com/full-feed/gadgets",
"engadgetsT" => "http://www.engadget.com/rss.xml",
"computerworldT" => "http://feeds.computerworld.com/Computerworld/News",
"techreviewT" =>"http://feeds.technologyreview.com/technology_review_top_stories",
"gizmagT" =>"http://www.gizmag.com/xml/",
"coolT" => "http://www.coolest-gadgets.com/feed/",
"newsweekT" => "http://feeds.newsweek.com/newsweek/TopNews",
"forbesT" => "http://www.forbes.com/technology/index.xml",
"howstuffworksT" => "http://feeds.howstuffworks.com/DailyStuff",
"infoworldT" => "http://www.infoworld.com/rss/news.xml",
"technoratiT" => "http://feeds09.technorati.com/trarticles?format=xml",
"cnetT" => "http://news.cnet.com/2547-1001_3-0-5.xml",
"zdnetT" => "http://www.zdnet.com/search?t=7&mode=rss",
"wiredT" => "http://feeds.wired.com/wired/index",
"popmechT" => "http://www.popularmechanics.com/rss/technology/",
"msnbcS" => "http://rss.nbcsports.msnbc.com/id/3032112/device/rss/rss.xml",
"espnS" => "http://sports.espn.go.com/espn/rss/news",
"yasportsS" => "http://sports.yahoo.com/top/rss.xml",
"cnnS" => "http://rss.cnn.com/rss/si_topstories.rss",
"foxsportsS" => "http://msn.com/rss/sports.aspx",
"nflS" => "http://www.nfl.com/rss/rsslanding?searchString=home",
"mlbS" => "http://mlb.mlb.com/partnerxml/gen/news/rss/mlb.xml",
"nbaS" => "http://www.nba.com/rss/nba_rss.xml",
'deadspinS" =>"http://deadspin.com/index.xml",
"usasportsS" => "http://content.usatoday.com/marketing/rss/rsstrans.aspx?feedId=sports1",
"eonlineE" =>"http://www.eonline.com/syndication/feeds/rssfeeds/topstories.xml",
"xtratvE" =>"http://feeds.feedburner.com/ExtraTV?format=xml",
"ewE" =>"http://rss.ew.com/web/ew/rss/todayslatest/index.xml",
"nasaE" =>"http://www.nasa.gov/rss/breaking_news.rss",
"tmzE" => "http://www.tmz.com/rss.xml",
"etoE" => "http://feeds.feedburner.com/ETTopStories",
"accessE" =>"http://www.accesshollywood.com/content/xml/rss/latest_news.xml",
"oddlyE" =>"http://feeds.reuters.com/reuters/oddlyEnoughNews",
"weatherE" =>"http://rss.weather.com/rss/national/rss_nwf_rss.xml?cm_ven=NWF&cm_cat=rss&par=NWF_rss",
"webmdE" => "http://rssfeeds.webmd.com/rss/rss.aspx?RSSSource=RSS_PUBLIC"
//no trailing comma after last RSS URL!!
);
////Beginners don't need to configure past here. Edit outputbody.php to format the output of each RSS item's body ////////////////////
$rssid=$_GET['id'];
$rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("<b>Error:</b> Can't find requested RSS in list.");
$cachetime=isset($_GET["cachetime"])? (int)$_GET["cachetime"] : 30; //Get cachetime. Default to 30 if not specified
$feednumber=isset($_GET["limit"])? (int)$_GET["limit"] : ""; //Get number of items to fetch. If not specified (""), all is fetched.
$templatename=isset($_GET["template"])? $_GET["template"] : ""; //get name of template, which is used by if/else logic within function outputbody()
if ($templatename!="" && !preg_match("/^(\w|-)+$/i", $templatename)) //Template name can only contain alphanumeric characters, underscore or dash (-)
die ("<b>Error:</b> Template name can only consist of alphanumeric characters, underscore or dash");
$feed->cache_max_minutes($cachetime);
$feed->feed_url($rssurl);
$feed->init();
$max = $feed->get_item_quantity($feednumber);
function outputitems(){
global $feed, $feednumber, $templatename;
$max = $feed->get_item_quantity($feednumber);
for ($x = 0; $x < $max; $x++){
$item = $feed->get_item($x);
outputbody($item, $templatename, $feed); //call custom outputbody() function
}
}
?>
<?php
if ($feed->data){
outputitems();
}
?>
Did I do this correctly??
Bookmarks