Skip to content

Instantly share code, notes, and snippets.

@abelsonlive
Last active December 16, 2015 10:39
Show Gist options
  • Save abelsonlive/5421242 to your computer and use it in GitHub Desktop.
Save abelsonlive/5421242 to your computer and use it in GitHub Desktop.
connect with twitter's api in python via tweepy
import tweepy
# api keys accessed from http://dev.twitter.com/apps
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
# now you can do stuff like this:
# get my last 20 tweets
my_tweets = api.user_timeline("brianabelson")
# these are formatted as a list of dictioaries
print my_tweets[0]
# tweet from python! (only works if your account is set to "read/write")
api.update_status("I'm tweetin from python, yo!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment