linux poison RSS
linux poison Email

Tweet from command line using curl

curl is a client to get documents/files from or send documents to a server, using any of the supported protocols (HTTP, HTTPS, FTP, GOPHER, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction or any kind of interactivity.

curl offers a busload of useful tricks like proxy support, user authentication, ftp upload, HTTP post, SSL (https:) connections, cookies, file transfer resume and more

curl is availabe mostly on all Linux distros but you can download a binary package from cURL's download page if you don't have it installed.

Open the terminal and past the below mentioned command to send the status to the twitter
curl --basic --user username:password --data status="Linux" http://twitter.com/statuses/update.xml
command explanation
--basic --user username:password

The above piece of code will authenticate your Twitter username and password.

--data status="Linux"

The above piece of code will send the data to the API i.e your new status which will be in the form of POST HTTP request.

http://twitter.com/statuses/update.xml

The main part of the code which is the URL of the Twitter API.


3 comments:

n2j3 said...

This will not obviously work after Aug 16 (when OAuth will be the only means of access). Any ideas on how to accommodate oauth with curl?

DevOps said...

Twistd is more generalised approach by providing a proxy that will sign HTTP requests with the required OAuth signatures. This saves you from having to deal with the internals of the OAuth yourself - you simply call your chosen OAuth web service through the proxy.

Twistd can be installed from the python-twisted-core package in Ubuntu. You run the proxy like:

twistd -n oauth_proxy \
--consumer-key \
--consumer-secret \
[--token ] \
[--token-secret ] \
[-p ] \
[--ssl]

Commands can then be sent via the local proxy using a command line tool such as curl like:

curl -x localhost:8001 http://host.name/path

Read more: http://www.brighthub.com/hubfolio/matthew-casperson/articles/74788.aspx#ixzz0sodXSuZ3

Anonymous said...

when I try to run command for tweeting from terminal.......following error comes.....


Basic authentication is not supported


but I enter correct username and password. please help

Post a Comment

Related Posts with Thumbnails