diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2019-05-26 18:17:49 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2019-05-26 18:17:49 +0530 |
commit | e5d413994cb23564abc9c42bf0ce2cc762222a6c (patch) | |
tree | b4cf9c4e4347c5d7c976087db81864f76fda75fe /pythonProgram/function-specific-programs/tweet.py | |
parent | 09a166342f3e022dc241551b06f7460e974f2117 (diff) |
Created python folder
Diffstat (limited to 'pythonProgram/function-specific-programs/tweet.py')
-rw-r--r-- | pythonProgram/function-specific-programs/tweet.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pythonProgram/function-specific-programs/tweet.py b/pythonProgram/function-specific-programs/tweet.py new file mode 100644 index 0000000..9903edd --- /dev/null +++ b/pythonProgram/function-specific-programs/tweet.py @@ -0,0 +1,43 @@ +""" +import tweepy + +#twitter application credentials +consumer_key="addYours" +consumer_secret="addYours" + +#twitter user credentials +access_token="AddYours" +access_token_secret="AddYours" + +auth = tweepy.OAuthHandler(consumer_key, consumer_secret) +auth.set_access_token(access_token, access_token_secret) + +tweepyapi = tweepy.API(auth) + +tweepyapi.update_status('Hello World!') +print("Hello " + tweepyapi.me().name) +""" + +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" : consumer_key, + "consumer_secret" : consumer_secret, + "access_token" : access_token, + "access_token_secret" : access_token_secret + } + + api = get_api(cfg) + tweet = "Hello, world!" + status = api.update_status(status=tweet) + # Yes, tweet is called 'status' rather confusing + +if __name__ == "__main__": + main() |