This is kindof a followup question to this question. I want to get the ID of the users that have retweeted a particular tweet.
I tried following the same technique but I'm getting an error. Here's the code:
import tweepy
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
firstTweet = api.user_timeline("github")[0]
print firstTweet.text
print firstTweet.id
results = api.retweeted_by(firstTweet.id)
print results
This returns the 1st tweet and also the tweet ID. It then gives me the following error:
Traceback (most recent call last):
File "twitter_test.py", line 21, in <module>
results = api.retweeted_by("357237988863913984")
File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 197, in _call
return method.execute()
File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 173, in execute
raise TweepError(error_msg, resp)
tweepy.error.TweepError: [{u'message': u'Sorry, that page does not exist', u'code': 34}]
GET statuses/show/:id Returns a single Tweet, specified by the id parameter. The Tweet's author will also be embedded within the Tweet.
In order to get the location we have to do the following : Identify the user ID or the screen name of the profile. Get the User object of the profile using the get_user() method with the user ID or the screen name. From this object, fetch the location attribute present in it.
If it's a retweet, the tweet will contain a property named retweeted_status . To be complete, retweeted_status will not appear if the tweet is not a retweet. More info at: Tweets.
retweeted_by
is not a part of 1.1 twitter API. Switch to retweets
:
results = api.retweets(firstTweet.id)
FYI, quote from docs:
GET statuses/retweeters/ids
Returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter.
This method offers similar data to GET statuses/retweets/:id and replaces API v1's GET statuses/:id/retweeted_by/ids method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With