-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitter.py
36 lines (26 loc) · 1.13 KB
/
twitter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import tweepy
auth = tweepy.OAuthHandler("PrVAMU3WgCL8yRyU0P8fnc1yU", "NUkAq6Y16N5FrPX2hsvRAQcn3B0mU85b3xyzHUmMpu0Vt6otBo")
auth.set_access_token("947744588697042945-AVjCrdprkbLGDr8RCxMC3XmO6ehQDXr", "KtioiJD8RNTHMvBSCce4VXnD1bqKTbym9Z1fwYNmXaveR")
api = tweepy.API(auth)
public_tweets = api.home_timeline()
print(public_tweets)
for tweet in public_tweets:
print(tweet.text)
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" : "PrVAMU3WgCL8yRyU0P8fnc1yU",
"consumer_secret" : "NUkAq6Y16N5FrPX2hsvRAQcn3B0mU85b3xyzHUmMpu0Vt6otBo",
"access_token" : "947744588697042945-AVjCrdprkbLGDr8RCxMC3XmO6ehQDXr",
"access_token_secret" : "KtioiJD8RNTHMvBSCce4VXnD1bqKTbym9Z1fwYNmXaveR"
}
api = get_api(cfg)
tweet = "Congrats to St. Peters"
status = api.update_status(status=tweet)
# Yes, tweet is called 'status' rather confusing
if __name__ == "__main__":
main()