Created
May 16, 2009 21:52
-
-
Save justinyost/112820 to your computer and use it in GitHub Desktop.
Generates an RSS feed from a pile of other RSS feeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php header("Content-type: text/xml charset=utf-8"); | |
//get the simplepie library | |
require_once('simplepie.inc'); | |
//grab the feeds | |
$feed = new SimplePie(); | |
$feed->set_feed_url(array( | |
'http://feeds2.feedburner.com/Yostivanich', | |
'http://twitter.com/statuses/user_timeline/7568942.rss', | |
'http://feeds.delicious.com/v2/rss/jtyost2', | |
'http://digg.com/users/jtyost2/history.rss', | |
'http://ws.audioscrobbler.com/1.0/user/jtyost2/recenttracks.rss', | |
)); | |
//enable caching | |
$feed->enable_cache(true); | |
//provide the caching folder | |
$feed->set_cache_location('cache'); | |
//set the amount of seconds you want to cache the feed | |
$feed->set_cache_duration(1800); | |
//init the process | |
$feed->init(); | |
//let simplepie handle the content type (atom, RSS...) | |
$feed->handle_content_type(); | |
//set number of items to be displayed | |
$total_articles = 15; | |
for ($x = 0; $x < $feed->get_item_quantity($total_articles); $x++) | |
{ | |
$lifestream_items[] = $feed->get_item($x); | |
} | |
$rssfeed = '<?xml version="1.0" encoding="utf-8"?>'; | |
$rssfeed .= '<rss version="2.0">'; | |
$rssfeed .= '<channel>'; | |
$rssfeed .= '<title>Justin Yost - Personal Lifestream</title>'; | |
$rssfeed .= '<link>http://lifestream.yostivanich.com</link>'; | |
$rssfeed .= '<description>The personal lifestream of Justin Yost, displaying live updates of Justin\'s online life.</description>'; | |
$rssfeed .= '<language>en-us</language>'; | |
$rssfeed .= '<copyright>Creative Commons Attribution 3.0 Unported License: http://www.yostivanich.com/ Justin Yost </copyright>'; | |
$rssfeed .= '<managingEditor>[email protected] (Justin Yost) </managingEditor>'; | |
$rssfeed .= '<webMaster>[email protected] (Justin Yost) </webMaster>'; | |
foreach ($lifestream_items as $item): | |
$feed = $item->get_feed(); | |
$rssfeed .= '<item>'; | |
$rssfeed .= '<title>' . $item->get_title() . '</title>'; | |
$rssfeed .= '<description>' . $item->get_title() . '</description>'; | |
$rssfeed .= '<link>' . $item->get_permalink() . '</link>'; | |
$rssfeed .= '<pubDate>' . $item->get_date('r') . '</pubDate>'; | |
$rssfeed .= '<guid isPermaLink="true">' . $item->get_permalink() . '</guid>'; | |
$rssfeed .= '<category>' . $item->get_title() . '</category>'; | |
$rssfeed .= '</item>'; | |
endforeach; | |
$rssfeed .= '</channel>'; | |
$rssfeed .= '</rss>'; | |
echo $rssfeed; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment