Skip to content

Instantly share code, notes, and snippets.

@nogweii
Created January 19, 2010 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nogweii/281253 to your computer and use it in GitHub Desktop.
Save nogweii/281253 to your computer and use it in GitHub Desktop.
An attempt at a CLI ruby OAuth Twitter client. Or at least the skeleton version
#!/bin/ruby
require 'rubygems'
require 'twitter_oauth'
@@config = YAML.load_file("config.yml") rescue nil || {}
@client = TwitterOAuth::Client.new(
:token => @@config[:token],
:secret => @@config[:secret]
)
if @client.authorized?
puts "yay! we're authorized!"
else
request_token = @client.request_token(
:oauth_callback => nil
)
session[:request_token] = request_token.token
session[:request_token_secret] = request_token.secret
puts "Please go this URL and authorize this application."
puts request_token.authorize_url #.gsub('authorize', 'authenticate')
puts "Press [Enter] to continue..."
gets
access_token = @client.authorize(
request_token.token,
request_token.secret,
:oauth_verifier => params[:oauth_verifier]
)
@@config[:token] = access_token.token
@@config[:secret] = access_token.secret
File.open("config.yml") do |out|
YAML.dump(@@config, out)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment