Last active
August 29, 2015 14:05
-
-
Save soramugi/449c49729a1841180e4e to your computer and use it in GitHub Desktop.
google検索した画像を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
require 'twitter' | |
require 'google-search' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV['consumer_key'] | |
config.consumer_secret = ENV['consumer_secret'] | |
config.access_token = ENV['access_token'] | |
config.access_token_secret = ENV['access_token_secret'] | |
end | |
images = Google::Search::Image.new(query: ENV['query']).all | |
while image = images.sample | |
begin | |
p client.update_with_media('', open(image.uri)) | |
break | |
rescue => e | |
p e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment