I want to use only these functions, so I implemented. If I feel like implementing other functions, I may do it.
Methods
set_auth(USERNAME, PASSWORD)
USERNAME: user name or email addres to log in Twitter.
PASSWORD: password to log in Twitter.
public_timeline()
returns list of Unicode Strings. To use this method, you don't need to call set_auth().
friends_timeline()
returns list of Unicode Strings. To use this method, you have to call set_auth() before.
If you have set wrong user name or password, IOError will be raised.
user_timeline(USER)
USER: User ID or screen name of whom you want to get timeline.
returns list of Unicode Strings.
If you have set wrong user name or password, IOError will be raised.
update(STATUS)
STATUS: content to be post. It should be Unicode String.
To use this method, you have to call set_auth() before.
If you have set wrong user name or password, IOError will be raised.
How to use
>>> import twitter
>>> t = twitter.Twitter()
>>> lines = t.public_timeline()
>>> for line in lines:
... print line.encode('utf-8')
>>> t.set_auth(USERNAME, PASSWORD)
>>> lines = t.friends_timeline() # this method returns list of Unicode Strings.
>>> for line in lines:
... print line.encode('utf-8')
>>> lines = t.user_timeline(USER) # this method returns list of Unicode Strings.
>>> for line in lines:
... print line.encode('utf-8')
>>> t.update(STATUS) # this method expects STATUS as Unicode String.
More simple way of using is to run just this script.
This
script expects 1st argument for USERNAME, and 2nd argument for
PASSWORD. If you input these 2 arguments, timeline of your friends
will be shown.
If you input 3rd or more arguments, these will be connected with SPACE and posted as your status.
I cut corners to handle exceptions. So,... BE CAREFUL.
Requirement
In this library,
urllib and
xml.dom.minidom are used.
So I think it can run Python
2.0 or later, but I just tried it on
2.5 and
2.6.
I do guarantee nothing, so please be careful in use.
Rights
I do NOT maintain any rights about this script, because it is pretty simple one. Please make fun.