micro-tweet – The Twitter Client That Fits In a Tweet

micro-tweet is an ultra-minimalist Twitter client that fits in a tweet. It can only do two things – display your friends tweets (one at a time) and post new tweets. It’s written in Python and works entirely from the command line.

Source Code

The source code of micro-tweet is exactly 137 characters, which is short enough to fit in a single tweet :

import sys,twitter as t;p=sys.argv;a=t.Api(*p[1:3]);m=a.GetFriendsTimeline()[0];print m.user.name+':',m.text;p[3:] and a.PostUpdate(p[3])

Installation

  1. Install Python.
  2. Install the simplejson library.
  3. Install the python-twitter library.
  4. Copy the client source code (above) and paste it into a new file. Save it as “micro-tweet.py”.

Usage

To run the client, execute micro-tweet.py using the Python interpreter and pass your Twitter username and password as the script arguments. This will output the latest tweet from your friends time line:

python micro-tweet.py username password

To post a status update, pass the tweet text as the third script argument. The following example will again output the latest tweet from your friends time line and post “Your tweet here!” (sans quotes) to Twitter:

python micro-tweet.py username password "Your tweet here!"

Note that the tweet text needs to be enclosed in quotes for it to be posted properly. Use "double quotes" on Windows and 'single quotes' on *nix-like systems. You will not receive any confirmation as to whether your tweet was posted successfully or not. To check, visit twitter.com or fire up a different Twitter client.

Why micro-tweet?

Just for fun 🙂

micro-tweet was a little project I did over the weekend. The goal was to see if I could squeeze the essential features of a “real” Twitter client – reading and posting tweets – into less than 140 characters. It also served as a nice work-out for my rusty Python skills.

And yes, I’m aware that using a pre-existing library to interface with the Twitter API might be considered “cheating”, but it would be downright impossible to fit the script into the size constraints without it. The API endpoint URLs alone would probably be long enough to push the script over the limit.

Related posts :

4 Responses to “micro-tweet – The Twitter Client That Fits In a Tweet”

  1. tem says:

    I have a shorter one:

    import micro_tweet

  2. rctorr says:

    vry vry nice, good job!! i love python !

Leave a Reply