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?):
read -p "What are you doing? " -e input
curl --basic --user username:password --data status="$input" http://twitter.com/statuses/update.xml > /dev/null
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
Here is the windows version of the script:
SET /P input="What are you doing? "
curl --basic --user username:password --data status="%input%" http://twitter.com/statuses/update.xml > NUL
You will have to download curl, and drop it somewhere in your %Path%.
[tags]twitter, stéphane kattoor, curl, bash, shell, perl, script[/tags]