Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python: How to post new status update from your terminal
import tweepy
# log in via codes provided by Twitter
consumer_key = 'enter your consumer key'
consumer_secret = 'enter your consumer secret'
access_token = 'enter your access token'
access_token_secret = 'enter your access token secret'
# this is for authentication by using OAuthHandler and set_access_token method
# from tweepy with a bunch of codes hidden to us
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
# main variables where we'll do all the twitter magic
api = tweepy.API(auth)
# if authentication was successful, should be able to see the name
# of my account printed out
# my application settings are set for "Read and Write"
# this line should tweet out my message to my account's timeline
# can’t update duplicate status
api.update_status(status = "Thanks for reading my Data Blog! :)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment