Created
October 25, 2012 09:09
-
-
Save kao/3951547 to your computer and use it in GitHub Desktop.
Random Winner on Twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example : ruby ./random_winner.rb theodoraFR 200 | |
require 'rubygems' | |
require 'twitter' | |
Twitter.configure do |config| | |
config.consumer_key = 'xxx' | |
config.consumer_secret = 'XXX' | |
config.oauth_token = 'id-xxx' | |
config.oauth_token_secret = 'XXX' | |
end | |
screen_name = ARGV[0] | |
limit = ARGV[1] | |
ids = Twitter.follower_ids(screen_name).ids | |
last_200 = ids[0..limit.to_i] | |
2.times do |i| | |
winner = Twitter.user(last_200[Random.rand(200).to_i]) | |
puts "Winner #{i + 1} : @#{winner.screen_name} [#{winner.name}]" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment