My own little Twitter client

No AJAX, Flash, or AIR; just HTML, but arranged the way I want it.

I’ve tried various Twitter clients, but usually just went back to the twitter.com web-based interface that people hate so much. My main complaint with it—and I saw no other clients that did any better—was that it showed tweets in reverse chronological order. Conversations and the multi-tweet mini-essays that some people write are difficult to read that way, so I decided to write my own little client.

It's easy to think of new features to add, but in its current state it scratches the itch that I had, so I'll leave it alone.

It’s a simple python script that uses the python-twitter interface. (The zipped distribution version there is a bit out of date; my script has a comment at the top about what to do.) My twitter client python script checks for a disk file that identifies the last tweet that I read, pulls all tweets since then, and then creates a web page showing those in chronological order. (Sample page here.) The little ← arrow after each entry lets you reply to that tweet if you’re logged in on the web client, and an additional, slightly different ↵ arrow lets you link back to a message being replied to. Mouseover text makes the meaning of the cryptic little arrows clearer.

I was going to also have the script check for new direct messages, but twitter sends me email the rare times that I actually get one of those, so I won’t miss any. I also considered adding entries showing the results of a twitter vanity search, but python-twitter doesn’t support the search interface and I have an RSS feed to alert me to that anyway. It’s easy to think of new features to add—when I tweeted that I was working on this, more suggestions started coming—but in its current state it scratches the itch that I had, so I’ll leave it alone.

Coding around twitter’s API is easy if you don’t want to implement a fancy UI. Some of the comments I received about features to add suggested easier following of threaded conversations, and the API gives you what you need to do that, once you decide on a UI. That’s how I added the link for the second arrow mentioned above.

For now, when I want to read recent tweets from my friends, I run a batch file that runs the python script and displays the resulting HTML file. I’ll probably make something to trigger it with a CGI so that I can check for updates by just clicking a button.

I’ve put the python script at http://www.snee.com/xml/twclient/getNewTweets.py.txt and the tweets.css stylesheet that the output references in the same directory. If you’ve never played with Twitter’s API, see part 1 and part 2 of my DevX article on it. python-twitter makes it pretty easy, but twitter’s RESTful native interface makes it easy to write a client in any language—even XSLT, if you use cURL to retrieve the data from the server, because while XSLT engines can do HTTP GETs, I know of none that can do the authenticated GETs required for most calls to the twitter API.

3 Comments

By Dorai Thodla on March 25, 2009 10:16 PM

Nice. I always wanted one which I can customize. For example, when some one follows you, I would like to click on the person’s account and get a tag cloud to see whether I have any interest in following them.

I don’t care much for AIR even though I use Twhirl a lot since it is easy to retweet.

Thanks for sharing.

regards,
Dorai

By Marty on April 16, 2009 5:46 PM

What do I do with the python script to run it on windows?

By Bob DuCharme on April 16, 2009 7:36 PM

First download it, rename it as getNewTweets.py, and change the lines that set the username and password to use your own.

I run it with a batch file that looks like this:

python getNewTweets.py > temp.html
temp.html