aboutsummaryrefslogtreecommitdiff
path: root/function-specific-programs/tweet.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2019-05-11 21:38:22 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2019-05-11 21:38:22 +0530
commit6cbd67bb7232e2ed499a1b94b51d255cbaea0183 (patch)
tree12dc138f9a9cc7607e146138a08db778dcc1e98c /function-specific-programs/tweet.py
parent395ea589cc10973ceae07768e7c6484534d17c8d (diff)
Initial Commit
Diffstat (limited to 'function-specific-programs/tweet.py')
-rw-r--r--function-specific-programs/tweet.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/function-specific-programs/tweet.py b/function-specific-programs/tweet.py
new file mode 100644
index 0000000..e9bfdfb
--- /dev/null
+++ b/function-specific-programs/tweet.py
@@ -0,0 +1,43 @@
+"""
+import tweepy
+
+#twitter application credentials
+consumer_key="knQFpTnjuSvr6OxYwebt3wyrd"
+consumer_secret="Mhex3oRkmaF7lD3hoMvHpAD6ctW0ugKYCopTlhc0JzOLOMIZ0w"
+
+#twitter user credentials
+access_token="2846631344-wEozinvHfEIFxFVy51I6te8SrN5OTFtU00wxsiz"
+access_token_secret="Nfx1U8a2TjAQXFLBrJIyy2p36sjBGAWFIthLc1cIoI56U"
+
+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" : "knQFpTnjuSvr6OxYwebt3wyrd",
+ "consumer_secret" : "Mhex3oRkmaF7lD3hoMvHpAD6ctW0ugKYCopTlhc0JzOLOMIZ0w",
+ "access_token" : "2846631344-wEozinvHfEIFxFVy51I6te8SrN5OTFtU00wxsiz",
+ "access_token_secret" : "Nfx1U8a2TjAQXFLBrJIyy2p36sjBGAWFIthLc1cIoI56U"
+ }
+
+ api = get_api(cfg)
+ tweet = "Hello, world!"
+ status = api.update_status(status=tweet)
+ # Yes, tweet is called 'status' rather confusing
+
+if __name__ == "__main__":
+ main() \ No newline at end of file