Last active
January 27, 2018 01:45
-
-
Save calistatee/0636c5d523eeeea5fb1a5e16118e201d to your computer and use it in GitHub Desktop.
Python: How to post new status update from your terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
print(api.me().name) | |
# 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