Last active
November 4, 2017 05:39
-
-
Save mattccrampton/dfc194e4a865e2c534d04cd13212056d to your computer and use it in GitHub Desktop.
Tweet from python using tweepy
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 | |
def get_api(cfg): | |
auth = tweepy.OAuthHandler(cfg['consumer_key'], cfg['consumer_secret']) | |
auth.set_access_token(cfg['access_token'], cfg['access_token_secret']) | |
return tweepy.API(auth) | |
def main(): | |
# Fill in the values noted in previous step here | |
cfg = { | |
"consumer_key" : "REPLACE_THIS_WITH_YOUR_CONSUMER_KEY", | |
"consumer_secret" : "REPLACE_THIS_WITH_YOUR_CONSUMER_SECRET", | |
"access_token" : "REPLACE_THIS_WITH_YOUR_ACCESS_TOKEN", | |
"access_token_secret" : "REPLACE_THIS_WITH_YOUR_ACCESS_TOKEN_SECRET" | |
} | |
api = get_api(cfg) | |
tweet = "Another day, another #scifi #book and a cup of #coffee" | |
status = api.update_status(status=tweet) | |
# Yes, tweet is called 'status' rather confusing | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment