Created
August 14, 2014 08:58
-
-
Save rinx/fbca904d68700dbea757 to your computer and use it in GitHub Desktop.
tweeting from commandline
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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'twitter' | |
CONSUMER_KEY = '' | |
CONSUMER_SECRET = '' | |
ACCESS_TOKEN = '' | |
ACCESS_SECRET = '' | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = CONSUMER_KEY | |
config.consumer_secret = CONSUMER_SECRET | |
config.access_token = ACCESS_TOKEN | |
config.access_token_secret = ACCESS_SECRET | |
end | |
if ARGV[0].nil? then | |
limit = 5 | |
else | |
limit = ARGV[0].to_i | |
end | |
i = 0 | |
while message = STDIN.gets | |
if message.length <= 140 then | |
client.update(message) | |
end | |
i += 1 | |
if i >= limit then | |
break | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment