-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (25 loc) · 1.02 KB
/
main.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
import tweepy,datetime,requests,json
def tweet():
consumer_key = "<consumer_key>"
consumer_secret = "<consumer_secret>"
access_token = "<access_token>"
access_token_secret = "<access_token_secret>"
quote_api_url = "https://andruxnet-random-famous-quotes.p.mashape.com/?cat=famous" #you can use movies instead of famous. See in description.
quoteData = requests.get(quote_api_url,headers={
"X-Mashape-Key": "<X-Mashape-Key>",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json"
}).json()
quoteJson = json.loads(json.dumps(quoteData))
quote = quoteJson['quote']
tweet = quote + ' #Tweetbot'
print (tweet)
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth)
api.update_status(tweet)
while (1):
current_time = datetime.datetime.today()
if(current_time.hour == 12 and current_time.second == 12):
tweet()
print("Tweeted")