Wikipedia Watchlist RSS

Wikipedia’s Watchlist has a RSS feed, which is a nice way to keep track changes on your watched articles. However, the RSS feed doesn’t seem to conform to the RSS standard, and confuses some feedreaders – notably, Opera M2.

Here’s a simple PHP script, which you can place on your website, that’ll fix the RSS feed. You’ll need to give it the URL to your RSS feed (which you can get by subscribing to your watchlist), since it contains your secret API key.

<?php
$rss_url = 'http://en.wikipedia.org/w/api.php'
	. '?action=feedwatchlist'
	. '&allrev=allrev'
	. '&hours=72'
	. '&wlowner=YOUR_USERNAME_HERE'
	. '&wltoken=YOUR_API_KEY_HERE'
	. '&feedformat=rss';
$feed = `wget -q -O - '$rss_url'`;
$rows = explode("\n", $feed);
header('Content-type: application/rss+xml');
foreach ($rows as $row)
{
	if (strpos($row, '<item>')!==false)
		$alldata = '';
	if (strpos($row, '<guid>')!==false)
		continue;
	$alldata .= $row;
	if (strpos($row, '</item>')!==false)
		$row = '<guid isPermaLink="false">' 
			. md5($alldata) 
			. "</guid>\n"
			. $row;
	echo $row . "\n";
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *