Skip to content

Instantly share code, notes, and snippets.

@nogweii
Created November 26, 2009 01:22
Show Gist options
  • Select an option

  • Save nogweii/243154 to your computer and use it in GitHub Desktop.

Select an option

Save nogweii/243154 to your computer and use it in GitHub Desktop.
Attempt at a simple Twitter CLI OAuth sample
#!/usr/bin/ruby
require 'twitter'
require 'pp'
oauth = Twitter::OAuth.new('key', 'secret');
rtoken = oauth.request_token.token
rsecret = oauth.request_token.secret
puts "> redirecting you to twitter to authorize..."
puts ">> #{oauth.request_token.authorize_url}"
print "> what was the PIN twitter provided you with? "
pin = gets.chomp
begin
oauth.authorize_from_request(rtoken, rsecret, pin)
twitter = Twitter::Base.new(oauth)
twitter.user_timeline.each do |tweet|
puts "#{tweet.user.screen_name}: #{tweet.text}"
end
rescue OAuth::Unauthorized
puts "> FAIL!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment