Skip to content

Instantly share code, notes, and snippets.

@hrysd
Created April 26, 2012 16:54
Show Gist options
  • Save hrysd/2500948 to your computer and use it in GitHub Desktop.
Save hrysd/2500948 to your computer and use it in GitHub Desktop.
RubyでFavoriteしましょう!!
#coding: utf-8
require 'twitter'
Twitter.configure do |config|
config.consumer_key = 'CONSUMER_KEY'
config.consumer_secret = 'CONSUMER_SECRET'
config.oauth_token = 'OAUTH_TOKEN'
config.oauth_token_secret = 'OAUTH_TOKEN_SECRET'
end
client = Twitter::Client.new
puts "誰に?"
who = gets.chomp
puts "どれくらい?"
number = gets.chomp
tweets = client.user_timeline(who, count: number)
tweets.each_with_index do |tweet, i|
puts "#{i}:#{tweet.text}"
begin
client.favorite_create(tweet.id)
puts 'fav'
rescue => error
puts error.message, "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment