For a long time I have mainly been reading Twitter with a generic RSS reader (newsbeuter). Recently this stopped working when twitter.com disabled ‘HTTP Basic Auth’ in preference of using OAuth. Now I can say a lot of good and bad things about OAuth, but to keep a short story short: It doesn’t work with generic RSS readers.
Instead of getting the RSS feed from a URL, my RSS reader can run a script that prints an RSS feed. So if I could just write a script that does the OAuth dance to convince twitter.com to give me an RSS feed?
Perl to the rescue! Or rather CPAN to the rescue: Net::Twitter::Lite have a nice simple example for setting up OAuth with a desktop application. It also provides access to most of Twitters REST API, but no method for retrieving generic URLs.
Using some Jedi mind tricks and reading the source I found a private and undocumented method _oauth_authenticated_request which does exactly what I need. It is quite simple:
- Get my script from gist.github.com/585710 and install the dependencies (Net::Twitter:Lite).
- Register you own app at dev.twitter.com to get a Consumer Key and Consumer Secret.
- Run the script once to setup access and get an Access Token and Access Token Secret.
- Run the script with an RSS feed url as parameter to get the RSS feeds.
Most interesting feed to follow is probably http://api.twitter.com/1/statuses/home_timeline.atom, which show the same as the home page on twitter.com would show you, and http://api.twitter.com/1/statuses/mentions.atom, which shows any tweet that mentions you.