めもめも。
とりあえずupdateだけ。basic認証且つPOSTで送信しないとダメのようだ。
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib
import urllib2
URL = 'http://twitter.com/statuses/update.xml'
USER = 'ryomatsu'
PASS = 'hoge'
def post(message):
postdata = {'status':message}
params = urllib.urlencode(postdata)
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('Twitter API',URL,USER,PASS)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
up = urllib2.urlopen(URL, params)
if __name__ == '__main__':
post('test')
Sponsored Link