Retrieve most retweeted tweets for a given hashtag

2019-03-15 17:55发布

I'd like to retrieve the tweets for given a hashtag and sort them from the most retweeted to the less retweeted.

The closest thing I've found is using the search call and use the type tag: E.g.: http://search.twitter.com/search.json?q=TheHashTagHere&result_type=popular

However, I'm not sure on how "popular" option works.

For instance, if it finds 100 tweets with that hashtag I believe it should show the X most retweeted tweets, and if none of those tweets have been retweeted then it should show X of them randomly (or sorted in some other way like the most recent).

Unfortunately, if follows some kind of unknown rule to identify what's popular and what not and even hashtags with thousands of tweets might return only one or two results.

I hope I made myself clear. Thanks in advance :)

PS: I'll use PHP but I think that shouldn't affect the question?

标签: twitter
2条回答
叛逆
2楼-- · 2019-03-15 18:45

Results will sometimes contain a result_type field into the metadata with a value of either "recent" or "popular". Popular results are derived by an algorithm that Twitter computes, and up to 3 will appear in the default mixed mode that the Search API operates under. Popular results include another node in the metadata called recent_retweets. This field indicates how many retweets the Tweet has had.

Source (Emphasis are mine)

Just call with result_type=popular and check the recent_retweets node to see how popular it is. result_type=popular will become the default in an upcome release so beware if you omit this parameter.

Results with popular tweets aren't ordered chronologically. *

If you would like to always have results to show, use result_type=mixed: they will have the result_type in the "metadata" section with a value of "recent", and popular results will have "popular". A small reference about result_types:

mixed: Include both popular and real time results in the response.

recent: return only the most recent results in the response

popular: return only the most popular results in the response.

If a search query has any popular results, those will be returned at the top, even if they are older than the other results. *

*[Twitter API Announcements]

查看更多
女痞
3楼-- · 2019-03-15 18:55

This isn't a programmatic method but rather works in the browser with a chrome extension (HackyBird) :

  • Install the extension
  • Search for a phrase e.g. #Social (twitter.com/search?q=%23Social)
  • Click the extension to sort it (you can adjust the ratio of retweets/likes used for sorting in extension options).

P.S. It'll also sort your or any other user's timeline.

查看更多
登录 后发表回答