using the twitter api with python, I need to know how to get all the user ids of all the people that retweeted a tweet.
I went here: https://dev.twitter.com/docs/api/1/get/statuses/%3Aid/retweeted_by
but I do not know how to put that into python.
here is my code so far:
from twitter import *
t = Twitter(auth=OAuth(....))
twitter = t.statuses.user_timeline.snl()
twitter[0]['text'] # gets the tweet
twitter[0]['retweet_count'] # gets the number of retweets
what is my next line to get the IDs of all the users who retweeted?
You should use retweets_of_me for twitter API 1.1, retweeted_by
is deprecated and doesn't work.
Here's an example:
from twitter import *
t = Twitter(auth=OAuth(...))
tweets = t.statuses.user_timeline.snl()
for tweet in tweets:
retweets = t.statuses.retweets_of_me(since_id=str(tweet['id']), max_id=str(tweet['id']))
print retweets
Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.