After encountering difficulties in posting to Twitter from the Bash shell, I decided to poke around more and found this tutorial by Phil Wilson. It uses the unofficial twitter python API methods (python-twitter)
However, I realized that installing python-twitter is a mini-task in itself. The comments section in the above article also indicated that Ubuntu Gutsy 'broke' certain functionality.
I use Ubuntu Gutsy 7.10 for its simplicity and ease of maintenance.(not to mention Compiz eye candy :D). I had already installed a ton of python-xxxxx packages from the repositories whenever they looked remotely useful for future dependencies. The following instructions worked word-for-word for me. So, if anything chokes on an obscure dependency on your distro, its upto the reader to look it up in your repositories (sorry guys/gals, i'm just human)
I'm no python Library Guru. However, I'm quite a purist with respect to NOT installing code that clogs up and refuses to be exorcised from my Linux system. Thankfully, Ubuntu repositories give me peace of mind 24/7 in this regard. But in this case, I had to get my feet wet.
Moving on, I was introduced to a little utility called easy_install that was required. Typing 'easy_' and pressing TAB showed me that easy_install was present somewhere in my shell's search path. Apparently, also among the dependencies for python-twitter is a python module(is it a module? citation needed.) called simplejson.
To install it, type:
sudo easy_install -U simplejson
(this assumes that easy_install is present and kicking on your box)
Next, head to the download section of the python-twitter project and download the latest source code archive (0.5 at time of writing)
Extract it using :
tar -zxvf python-twitter-0.5.tar.gz
cd into the extracted directory:
cd python-twitter-0.5/
and run the following commands :
python setup.py build
and
sudo python setup.py install
(enter your user password in Ubuntu for using sudo, in case anyone hasn't used sudo before)
and finally to test if the API works run :
python setup.py test
you should see something like a bunch of test results terminated by :
"Ran 36 tests in 0.631s
OK"
This is now officially the first trivially complete python-twitter install tutorial on the internet :D
(for further troubleshooting, in case you're using a different distribution with incomplete dependencies, refer to the comments section of the Original article on philwilson.org.)
Now, to actually see the twitter POST functionality, cd into the python-twitter-0.5/examples sub-directory in your HOME, (you should know how to use 'cd' by now),
cd ~/python-twitter-0.5/examples
and type in:
python tweet.py --username YOUR_USERNAME --password YOUR_PASSWORD this is my test post from python-twitter
My Output was:Vimal George just posted: this is my test post from python-twitter
Sweet! , your first command line tweet. That wasn't so hard eh?
... to be continued (i.e when I figure out the rest ... :D)
Happy tweeting ladies and laddies; my twitter id is vimalg2
1 comments:
openid testing
Post a Comment