Friday, January 18, 2008

fun with python: been twitter'ing with python

I'm not sure why, but python developer seems have ways to write python modules, to integrate with web service. Which to me interesting. There is one from google to integrate, google service. There is one for flickr, which I covered. Etc. Even twitter have one.

The twitter python binding can be found in
Before you install it, you need to install simplejson.

To install simplejson, it is just get the tar.gz file. Then uncompress it,
Then in the same directory
On ubuntu:
sudo python install
on other linux as root:
python install
same on windows. just:
python install

The process of installing the python-twitter is the same cycle of python

There is a few standard thing we can do with the python-twitter module.

here I assume that, you run it, in a python shell, it is just a follow along tutorial here, and the >>> is not shown:
before that, import the module
import twitter
start using it, you need to authenticate yourself, using your twitter username and password.
to view public time line
for s in status:
print s.text
or you can just
print [s.text for s in status]
to view a user status, just replace user with the username of the user
then read it by
print [t.text for t in userStatus]
Here is the important one, to post your own status using the python-twitter module
posting=apt.PostUpdate("your status")
There you go, few way to use python to interface with twitter. You can use this with a gui front end, or integrate with django, etc.

No comments:

Post a Comment