Skip to content

Instantly share code, notes, and snippets.

@Shaz3e
Created March 1, 2014 20:30
Show Gist options
  • Save Shaz3e/9296780 to your computer and use it in GitHub Desktop.
Save Shaz3e/9296780 to your computer and use it in GitHub Desktop.
Get RSS Feeds using PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>RSS Feeds</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<?php
$feedname = 'TechCrunch/'; // feedname/ or feed/
$url = 'http://feeds.feedburner.com/'; // http://feeds.feedburner.com/ or http://website.com/
$rss = simplexml_load_file($url.$feedname);
$feed = '<h3>'.$rss->channel->title.'</h3>';
foreach($rss->channel->item as $item){
//echo '<div class="rss">';
$feed .= '<h4><a href="'.$item->link.'">' . $item->title . '</a></h4>';
//$feed .= '<date>'.$item->pubDate.'</date>';
//$feed .= '<description>'.$item->description.'</description';
//echo '</div>';
}
echo $feed;
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment