Skip to content

Commit 3fc2562

Browse files
committed
added twitter api
1 parent 9f035a6 commit 3fc2562

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

21_twitter_bot.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import tweepy
2+
3+
# Authentication credentials - dev.twitter.com
4+
cfg = {
5+
'consumer_key': 'VALUE',
6+
'consumer_secret': 'VALUE',
7+
'access_token': 'VALUE',
8+
'access_token_secret': 'VALUE'
9+
}
10+
11+
12+
def get_api_handler(cfg):
13+
auth = tweepy.OAuthHandler(cfg['consumer_key'], cfg['consumer_secret'])
14+
auth.set_access_token(cfg['access_token'], cfg['access_token_secret'])
15+
return tweepy.API(auth)
16+
17+
18+
def main():
19+
api = get_api_handler(cfg)
20+
tweet = 'Hello, world from Tweepy!'
21+
api.update_status(status=tweet)
22+
23+
24+
if __name__ == "__main__":
25+
main()

0 commit comments

Comments
 (0)