Python Twitter API を使ってみる

Python Twitter API
sixohsix/twitter · GitHub

c:\tmp>pip install twitter
Downloading/unpacking twitter
Installing collected packages: twitter
Successfully installed twitter
Cleaning up...
# https://github.com/sixohsix/twitter
 
from twitter import *
import os.path
 
CONSUMER_KEY = 'brabrabra'
CONSUMER_SECRET = 'brabrabra'
 
MY_TWITTER_CREDS = os.path.expanduser('~/.my_app_credentials')
if not os.path.exists(MY_TWITTER_CREDS):
    oauth_dance("My App Name", CONSUMER_KEY, CONSUMER_SECRET, MY_TWITTER_CREDS)
 
oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS)
 
twitter = Twitter(auth=OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET))
 
for t in twitter.statuses.user_timeline(screen_name='dechnostick'):
    print(t['text'])