Does any one know how do I find users who all favorited / liked a tweet given tweet ID using Tweepy (Python Twitter api wrapper)?
I can get retweeters but not fav. I see that api.favorite
exists but the response there is binary.
As far as I know, getting a list of users who favorited a tweet is not available in Twitter's Rest API.
api.favorite()
is used for "favoriting" a status with the user you're logged in with.
See also: Twitter API - Getting list of users who favorited a status
You can get new "favorites" of tweets posted by your user (the one whose credentials you used for the OAuth login), using the streaming API. But you won't be able to get historical data this way.
The code for it would be something like this:
import json
import tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
class MyStreamListener(tweepy.StreamListener):
def on_event(self, status):
print(status)
print(status.event)
if status.event == 'favorite':
pass # handle event here
myStream = tweepy.Stream(auth = api.auth, listener=MyStreamListener())
myStream.userstream()