How to find all “retweets with comments” for a specific use using the API?

I want to get all the “tweets with comments” tweets.

Here are a few things I noticed with twitter api

Is there a way to find all the “tweets / retweets with comments” if you can provide the Tweet / Id source code?

+6
source share
2 answers

So, you mean Quoted Tweets (retweet with comments). There is no official method for the REST API yet, however there are several ways to do this.

  • Since all quoted tweets contain the short URL of the original, you can still use in_reply_to_status_id and filter by the short URL of the original twitter
  • Search for tweets containing the quoted_status_id field can be performed either through REST or through the STREAMING API.

quoted_status_id: This field appears only when Tweet is a Tweet quote. This field contains the integer value Tweet ID of the quoted Tweet.

+4
source

This is not easy to accomplish. Here's the brute force API method for finding Quote tweets.

Take your identifier, it will be something like 750176081987014657 .

GET search / tweets

Use the Twitter API and find the tweet.

https://dev.twitter.com/rest/reference/get/search/tweets

A 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 id of the tweet. I set the result argument to count max (100).

Login

Of course, with the Twitter API, there is a whole bunch of complicated authorization header work that you have to do to complete the GET request. This is documented elsewhere and is beyond the scope of this answer.

Results and Conclusions

When you have the JSON results of this GET request, focus on the statuses collection. For each tweet in the collection (otherwise called “status”), check to see if it contains the quoted_status_id field. If so, and the field value matches your tweet id, the tweet is the tweet tweet. If it is not, it is simply retweet without comment. You will also have to deal with iteration through pagination of the results if there are more than 100. This is done by looking for the search_metadata.next_results field and extracting the next GET request line from it, which will be provided to you.

0
source

All Articles