Archive for the 'twimi' Category

Twimi

Tuesday, September 9th, 2008

You might remember that like a 100 years ago I posted a small snippet of code showing you how to post Twitter updates using nothing but curl. Well, I took that snippet of code, polished it up a bit and re-branded it as Twimi and posted it on Google Code under GPL. I know, I know - the script proper is like 3 lines long and it doesn’t really do anything other than calling curl. I’m pretty sure you could whip up a way better script like 5 minutes. Why the hell would I put up something so trivial up there?

Well, for one I noticed that other people did the same thing. Both ktwitter and ZenTwitter are similarly simple, and yet they show up as “Linux Apps” on the Twitter Fan Wiki. Both scripts seem no more complex than what I wrote so why the hell not call my script an “twitter client app”?

The thing is that if you have a twitter client project which has it’s own website you can request a custom source parameter for it. So you can sort of brand it. Previously every time I posted using my script, the twitt showed up as “from web”. Now, it says “from twimi” and links to the google code page for the project which is a nice touch. So I pretty much uploaded it up there just to get that custom link underneath my twitts every once in a while. )

The second reason for posting it there is perhaps some sort of small glimmer of hope that some shell scripting guru will be willing to contribute to it and add new cool features to it. Right now it is very simple an minimalistic. It is a starter script that you can take and modify to make your own curl based client. I’m not going to post the code here because you can just easily browse it on the project page. It’s only about 60 lines of code, not counting the comments, and GPL boilerplate. If you want to contribute let me know and I’ll add you to the project and you can hack away at it and perhaps the thing will grow on it’s own. I don’t really care for the direction we take it in. I don’t care if it grows a front end of some sort, or if you decide to toss curl in favor of something else.

I know this is not a real project. But, everyone knows a little bash, right? And everyone can write a better script than this in 5 minutes or less, right? So just do it!

Suggestions, comments and contributions are as always appreciated.

Posting Twitter Updates via Curl

Monday, March 19th, 2007

Here is how to post an update to twitter using just curl and nothing else. I guess you can use this if you are working on some headless unix machine that doesn’t have a proper browser… Of course a machine that has curl would also probably have lynx or elinks but I digress.

Here is how you update twitter with curl:

curl --basic --user username:password --data status="I'm twittering with curl!" http://twitter.com/statuses/update.xml

That’s it! That’s all you have to do. I was actually quite surprised when I found out it’s this easy. And yes, I can’t take any credit for discovering it - I shamelessly stole the idea from Stéphane Kattoor. If you read Stéphane’s post, you will see that the relative ease of posting regular updates, is balanced by totally super retarded mechanics of sending direct messages.

It turns out that curl is not the best way to send them - perl + lwp is.

Based on Stéphane’s notes I wrote a this bash script that lets you send updates. I suppress the xml output and you get the standard curl time counter when you post (let’s say this is a poor man’s progress bar ok?):

#!/bin/bash
read -p "What are you doing? " -e input
curl --basic --user username:password --data status="$input" http://twitter.com/statuses/update.xml > /dev/null
echo "OK"

I’m using the read function, but I could easily convert this to use Xdialog or another graphical input grabbing tool. It would also be worthwhile incorporating Stéphane’s perl script for direct messaging while I’m at it.

Heh… I could actually combine this with my time logging script and have it pop-up and nag me for input every n hours. P

Update 03/19/2007 08:19:21 PM

Here is the windows version of the script:

@echo off
SET /P input="What are you doing? "
curl --basic --user username:password --data status="%input%" http://twitter.com/statuses/update.xml > NUL
echo OK

You will have to download curl, and drop it somewhere in your %Path%.