Reputation: 902
I'm using the twitter streaming API to catch tweets that contain a certain phrase. In the tweet JSON, is there a way to see if a user is following me (ie if the tweet author is following the authenticated user which initiated the stream)?
I noticed that tweets have a tweetObject.user.following property, but when that's true, it seems to be because I am following the tweet's author, not the other way around.
Is there a way to accurately see if the tweet's author is following me, rather than do a request for my followers list and compare against that for every new tweet?
Thanks if anyone can give some info!
Upvotes: 0
Views: 266
Reputation: 158
Twitter REST API has a method to show user relationship data. See the documentation on https://dev.twitter.com/rest/reference/get/friendships/show. It says:
Returns detailed information about the relationship between two arbitrary users.
The response contains following
and followed_by
fields in source
and target
user. This is the result sample:
{
"relationship": {
"target": {
"id_str": "12148",
"id": 12148,
"screen_name": "ernie",
"following": false,
"followed_by": false
},
"source": {
"can_dm": false,
"blocking": null,
"muting": null,
"id_str": "8649302",
"all_replies": null,
"want_retweets": null,
"id": 8649302,
"marked_spam": null,
"screen_name": "bert",
"following": false,
"followed_by": false,
"notifications_enabled": null
}
}
}
I don't know if this can help you when using streaming API. But at least, you don't have to "do a request for my followers list and compare against that for every new tweet" like you've said above.
Upvotes: 1