Family, Work, Life

Howto extract all followers from twitter into list of RSS feeds

I had this idea to use build a real distributed microblogger system a while ago. Unfortunately I was a little bit to late and twitter lost so many links between users (follow and followers) this night. But better now then never. I will post here from time to time parts of the pig picture how to build such a system. This time how to extract the list of friends from your Twitter account and generate a list of RSS feeds out of it.

Twitter has a cool API wich we can use legally. The xml list of users you follow can be retrieved with

http://twitter.com/statuses/friends/USERNAME.xml?lite=true&page=1..n (for me its ansi)

Having at the moment 112 user I follow (yesterday more then 160. :-( ) page 1 and 2 are all my guys.

This small xsl stylesheet extracts the userids. (if anyone is into xsl please help me here. Would be great to extract username, realname and user with comma separated per line. Please add comments if you know the solution, I appreciate it!)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 <xsl:strip-space elements="*"/>

 <xsl:template match="/users/user">
     <xsl:for-each select="id">
      <xsl:value-of select="." />
      <xsl:text>&#10;</xsl:text>
     </xsl:for-each>
 </xsl:template>

Save this code snip to a file called extractIDs.xslt and call it with the processor:

xsltproc extractIDs.xslt friendsPage1.xml  | sed 1d >list_of_ids.txt
xsltproc extractIDs.xslt friendsPage2.xml  | sed 1d >>list_of_ids.txt

So now next step howto get the rss feeds out of it. The API offers this call

http://twitter.com/statuses/user_timeline/USERID.atom

Short bashscript like

 for i in `cat list_of_ids.txt`
 do
  echo "http://twitter.com/statuses/user_timeline/$i.atom" >>list_of_rrs_feeds.txt
 done

is doing the job. So we end up with a text file each line with one RSS feed. I totally agree its much easier at the moment to call the “user and friend” rss feed from twitter but the idea behind this is to get a list of each user so future systems can really be distributed among many microblogging systems.

  • Share/Bookmark

3 Responses to “Howto extract all followers from twitter into list of RSS feeds”

  1. very handy thanks!

  2. The style of writing is quite familiar . Have you written guest posts for other bloggers?

  3. wats the best site to get twitter backgrounds?

Leave a Reply