Skip to content

Instantly share code, notes, and snippets.

@hideshi
Last active December 30, 2015 16:49
Show Gist options
  • Save hideshi/7857171 to your computer and use it in GitHub Desktop.
Save hideshi/7857171 to your computer and use it in GitHub Desktop.
How to post message to your twitter account through twitter api.
from twitter import Twitter, OAuth, TwitterHTTPError
# If you have twitter account,
# Register your app on https://dev.twitter.com so that you can get these information.
OAUTH_TOKEN = 'xxxx'
OAUTH_SECRET = 'xxxx'
CONSUMER_KEY = 'xxxx'
CONSUMER_SECRET = 'xxxx'
api = Twitter(auth = OAuth(OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET))
try:
api.statuses.update(status = 'Post message')
except TwitterHTTPError as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment