Reputation: 6647
I want to get all the 'retweets with comments' of a tweet.
Here are few things I noticed with twitter api
Is there a way to find all the 'tweet/retweet with comment' if you can supply the original Tweet/Id?
Upvotes: 10
Views: 11550
Reputation: 3300
This isn't easy to accomplish. Here's the brute-force API method to find Quote Tweets.
Take your tweet id, it'll be something like 750176081987014657
.
GET search/tweets
Use the Twitter API and search for the tweet.
https://dev.twitter.com/rest/reference/get/search/tweets
The GET request will look something like this:
https://api.twitter.com/1.1/search/tweets.json?q=750176081987014657&count=100
The q
"query" argument is the tweet id. I've set the result count
argument to the maximum (100).
Authorization
Of course with the Twitter API there's a whole bunch of tricky Authorization header work you have to do as well in order to complete the GET request. That's documented elsewhere and is beyond the scope of this answer.
Results and Conclusion
When you have the JSON results of this GET request, focus on the statuses
collection. For each tweet in the collection (otherwise known as a "status"), check if it contains a quoted_status_id
field. If it does, and the field value matches your tweet id, the tweet is a quote tweet. If it does not, it is simply a retweet with no added comment. You will also have to deal with iterating through the pagination of results if there are more than 100. That's done by looking for a search_metadata.next_results
field and retrieving the next GET query string from it, which will be provided for you.
Upvotes: 0
Reputation: 15953
So you're referring to Quoted Tweets (retweet with comments). There is no official method for that from the REST API yet, however, there are couple of ways to do it.
in_reply_to_status_id
and filter by short url of the original tweetquoted_status_id
this can be done either through REST or STREAMING API.quoted_status_id: This field only surfaces when the Tweet is a quote Tweet. This field contains the integer value Tweet ID of the quoted Tweet.
Upvotes: 9