forked from silshack/tweethack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweethack.py
43 lines (37 loc) · 1.44 KB
/
tweethack.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
37
38
39
40
41
42
43
from twython import Twython
from creds import *
twitter = Twython(APP_KEY, APP_SECRET, FINAL_OAUTH_TOKEN, FINAL_OAUTH_TOKEN_SECRET)
quit = ""
while quit != True:
exit = ""
tos = raw_input("Would you like to tweet, search, or exit? (tweet, search or quit) ")
if tos == "quit":
quit = True
elif tos == "tweet":
print "Let's tweet from the command line!"
while exit != True:
tweet = raw_input("What would you like to tweet? ")
twitter.update_status(status = tweet)
exit = raw_input("Type exit to go back or press enter to Tweet again. ")
if exit == "exit":
exit = True
elif tos == "tweet pictures":
print "Let's tweet a picture from the command line!"
while exit != True:
tweet = raw_input("What would you like to tweet? ")
photo = open('img/unc.jpg','rb')
twitter.update_status_with_media(status = tweet, media = photo)
exit = raw_input("Type exit to go back or press enter to Tweet again. ")
if exit == "exit":
exit = True
elif tos == "search":
print "Let's search from the command line!"
while exit != True:
query = raw_input("What would you like to search? ")
result = twitter.search(q=query, result_type='popular')
tweets = result['statuses']
for tweet in tweets:
print tweet['text']
exit = raw_input("Type exit to go back or press enter to search again. ")
if exit == "exit":
exit = True