Created
February 5, 2016 18:18
-
-
Save takouhai/e05d8e20085a51ca1a69 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# encoding: utf-8 | |
namespace :post do | |
desc 'Post Tweet' | |
task tweet: :environment do | |
puts 'Post Tweet' | |
twitter = Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV['TWITTER_CONSUMER_KEY'] | |
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET'] | |
config.access_token = ENV['TWITTER_ACCESS_TOKEN'] | |
config.access_token_secret = ENV['TWITTER_ACCESS_SECRET'] | |
end | |
param = Parameter.where(name: 'twitter').first | |
content = Content.where("name like ? and name like ?", "%\#devHangout%", "%" + param.value.to_s + "%").sort_by{|e| e[:id]}.first | |
Rails.logger.info 'Tweeting: ' + content.name + " https://youtu.be/" + content.provider_id | |
twitter.update(content.name + " https://youtu.be/" + content.provider_id) | |
param.value = param.value + 1 | |
param.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment