Monday, May 04, 2009

Twitter post by curl

Recently I explore the twitter - such nice short messages blog, seems very popular last time cause of mobile device support. Unfortunately, the Linux support is not strong: the Mozilla Firefox plugin - TwitterFox or Tircd I use with IRC client. Thanks for explanation and my respect to yaloki.
Twitter service is working by http protocol, so easy to post messages there via `curl'. Let's write some small BASH script:
#!/bin/bash
#
curl --basic --user USERNAME:PASSWORD --data status="$*" \
'http://twitter.com/statuses/update.xml' -o /dev/null

Let's call it `tw', make it executable and run as:
tw "My test messages to twitter"

Check result on http://twitter.com/yourpage
Cheers

UPDATE: HERE the detailed article
UPDATE2: The above method was ceased to work after August 16th, 2010 when Twitter removes basic authentication support from the API. Instead, all Twitter clients will need to use more secure authentication based on OAuth. The great article about how to do it in python is HERE. Thanks to @Jeff Miller for great explanation.

No comments: