Created
May 26, 2014 23:07
-
-
Save adamloving/f87489caef86acc475d7 to your computer and use it in GitHub Desktop.
Post several links to twitter feed
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
#!/usr/bin/env ruby | |
# foreman run script/social/auto-tweet.rb data/crawl-data.json | |
require 'Twitter' | |
require 'json' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = ENV['TWITTER_API_KEY'] | |
config.consumer_secret = ENV['TWITTER_API_SECRET'] | |
config.access_token = ENV['TWITTER_ACCESS_TOKEN'] | |
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET'] | |
end | |
urls = JSON.parse(File.open(ARGV.first).read) | |
# todo. add hashtags | |
for url in urls[2..50] | |
text = url['description'] || url['title'] | |
tweet = "#{text[0..100]} #{url['url']}" | |
client.update(tweet) | |
Kernel.sleep(2) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires a data file in the format: