Twittering from the command line.

Varun Kashyap shows us a way to start twittering from the command line. All you need to have is curl. curl is a command line tool for transferring files with URL syntax. Check out the following commands:
  • Get the public timeline, unauthenticated: curl
  • Get your friends timeline, authenticated: curl -u email:password
  • Just the headers, please: curl –head -u email:password
  • Post a status update, authenticated: curl -u email:password -d status="your message here"

These are mentioned over at the Twitter API page. However you can take this step further and write your own script so that you don’t have to type the lengthy commands over and over again and perhaps not even the email and password if you are okay with storing them in a script file. Here is an example (feel free to copy and paste):


twitterName="<<<Your twitter username here>>> "
password="<<<Your password here>>> "

$curl –basic –user "$twitterName:$password" –data-ascii \
"status=`echo $@ | tr ‘ ‘ ‘+’`" \

exit 0

Please note that its –basic (2 dashes), –user (2 dashes) and –data-ascii (2 dashes). Give the file a name such as "myTwitterer". Then you can simply type "myTwitterer <Your status update here>" and you status will be updated right from your command line. Be aware that the password will be stored in the script file without any encryption or security measures, however this file will reside on your local machine so its reasonably safe to do this.

Similarly you can use the other URLs I mentioned and get timelines both public and your friends! The whole processes can be down on windows as well all you need is cURL which you can get here.

Technorati Tags:

No comments: