forked from ideoforms/python-twitter-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitter-list-retweets.py
executable file
·41 lines (33 loc) · 1.69 KB
/
twitter-list-retweets.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
#!/usr/bin/python
#-----------------------------------------------------------------------
# twitter-retweets
# - print who has retweeted tweets from a given user's timeline
#-----------------------------------------------------------------------
from twitter import *
user = "ideoforms"
#-----------------------------------------------------------------------
# load our API credentials
#-----------------------------------------------------------------------
config = {}
execfile("config.py", config)
#-----------------------------------------------------------------------
# create twitter API object
#-----------------------------------------------------------------------
twitter = Twitter(
auth = OAuth(config["access_key"], config["access_secret"], config["consumer_key"], config["consumer_secret"]))
#-----------------------------------------------------------------------
# perform a basic search
# twitter API docs: https://dev.twitter.com/docs/api/1/get/search
#-----------------------------------------------------------------------
results = twitter.statuses.user_timeline(screen_name = user)
#-----------------------------------------------------------------------
# loop through each of my statuses, and print its content
#-----------------------------------------------------------------------
for status in results:
print "@%s %s" % (user, status["text"])
#-----------------------------------------------------------------------
# do a new query: who has RT'd this tweet?
#-----------------------------------------------------------------------
retweets = twitter.statuses.retweets._id(_id = status["id"])
for retweet in retweets:
print " - retweeted by %s" % (retweet["user"]["screen_name"])