Skip to content

Instantly share code, notes, and snippets.

@moomerman
Forked from nogweii/gist:281253
Created January 20, 2010 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moomerman/281760 to your computer and use it in GitHub Desktop.
Save moomerman/281760 to your computer and use it in GitHub Desktop.
#!/bin/ruby
require 'rubygems'
require 'twitter_oauth'
session = {}
@@config = YAML.load_file("config.yml") rescue nil || {}
@client = TwitterOAuth::Client.new(
:consumer_key => 'vikU4jhQVoXoF6e8WCfw3g',
:consumer_secret => 'xen6qlmau7hkaPvppRMoK76f9E9oB1SVQaDmPcMuAc',
: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 "Enter the PIN number you receive from Twitter and press [Enter] to continue..."
pin = gets.strip!
access_token = @client.authorize(
request_token.token,
request_token.secret,
:oauth_verifier => pin
)
@@config[:token] = access_token.token
@@config[:secret] = access_token.secret
File.open("config.yml", 'w') 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