Skip to content

Instantly share code, notes, and snippets.

@aont
Last active December 19, 2015 09:09
Show Gist options
  • Select an option

  • Save aont/5931504 to your computer and use it in GitHub Desktop.

Select an option

Save aont/5931504 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'twitter'
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
q = "aont"
res = Twitter.search(q, :count => "100")
statuses = res.statuses
while res.next_results?
res = Twitter.search(q, res.next_results);
statuses.concat(res.statuses)
end
twsort = statuses.sort do |a, b|
a.retweeters_count <=> b.retweeters_count
end
twsort.each do |s|
printf "http://twitter.com/%s/status/%s\n", s.from_user, s.id
printf "\t%s\n", s.text.gsub("\n", " ")
printf "\tfav:%s\trt:%s\n", s.favorite_count, s.retweeters_count
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment