Scripting Twitter with Perl + LWP
March 18th, 2007 by Stephane KattoorA little follow up on yesterday article about scripting Twitter with cURL: the solution was working, but somehow inconvenient. Not practical to have to go and fetch the user id every time you want to send a direct message !
This time, I scripted Twitter direct message with Perl and LWP (libwww-perl), for a much more convenient solution. I designed it to be used like a sort of universal paging service.
Running the script
Simply launch the script to get the usage :
spaghetti% ./twitter-direct.pl
Usage:
twitter-direct.pl --login login --password password --to user --text
"text to send"
Options:
–login
lets you specify the login of your Twitter account
–password
lets you specify your password
–to
the target user of the message
–text
the direct message to send
So for example :
spaghetti% ./twitter.pl --login mylogin --password mypassword --to "mybuddy" --text 'Hi ! Want to go to the movie ?'
That’s it !
Download

Related
- Here is another command line tool for twitter : Twitish.
- Twitter in a color Terminal


















March 18th, 2007 at 20:28
[...] Scripting Twitter with Perl + LWP : a script in Perl doing the same thing (much simpler). [...]
March 19th, 2007 at 20:58
[...] It turns out that curl is not the best way to send them – perl + lwp is. [...]
April 7th, 2007 at 22:43
Awesome. I should make good use of this, merci !
June 24th, 2007 at 1:12
thanks for your posts..great share for learners
March 3rd, 2009 at 4:30
[...] Scripting Twitter with cURL cURL is a versatile command-line utility designed to script Web page interactions. As a little demo, this tutorial shows you how to use it to easily to overcome the shortcomings of Twitter’s API. You can also view the Perl + LWP version of this tutorial here: Scripting Twitter with Perl + LWP [...]
March 3rd, 2009 at 13:55
[...] Scripting Twitter with cURL cURL is a versatile command-line utility designed to script Web page interactions. As a little demo, this tutorial shows you how to use it to easily to overcome the shortcomings of Twitter’s API. You can also view the Perl + LWP version of this tutorial here: Scripting Twitter with Perl + LWP [...]
March 6th, 2009 at 7:25
[...] Scripting Twitter with cURL cURL is a versatile command-line utility designed to script Web page interactions. As a little demo, this tutorial shows you how to use it to easily to overcome the shortcomings of Twitter’s API. You can also view the Perl + LWP version of this tutorial here: Scripting Twitter with Perl + LWP [...]
March 13th, 2009 at 9:50
[...] sending direct messages though (if you do want to send direct msgs on the CLI via perl check out this post by Stéphane [...]
June 6th, 2009 at 10:53
[...] Scripting Twitter with cURL cURL is a versatile command-line utility designed to script Web page interactions. As a little demo, this tutorial shows you how to use it to easily to overcome the shortcomings of Twitter’s API. You can also view the Perl + LWP version of this tutorial here: Scripting Twitter with Perl + LWP [...]