Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve most retweeted tweets for a given hashtag

Tags:

twitter

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?

like image 516
ozke Avatar asked May 18 '11 14:05

ozke


People also ask

How do I find my most liked tweet on a hashtag?

So now, you can use the Twitter filter to find out the most liked tweet or you can create a Tweet Binder PRO report in order to easily have it within your reports' metrics.

How do I see retweet history?

Go to your Notifications tab. There you will see all activity concerning your Tweets—including which have recently been Retweeted and by whom. From the Tweet detail page, you'll be able to see how many Retweets of your Tweet there are, in additon to how many Quote Tweets there are.


2 Answers

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]

like image 105
GmonC Avatar answered Oct 24 '22 16:10

GmonC


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.

like image 39
John S Avatar answered Oct 24 '22 17:10

John S