Skip to content

Instantly share code, notes, and snippets.

@dpickett
Created September 1, 2010 02:09
Show Gist options
  • Select an option

  • Save dpickett/560110 to your computer and use it in GitHub Desktop.

Select an option

Save dpickett/560110 to your computer and use it in GitHub Desktop.
def update(message)
client.update(message)
end
def client
authorize
Twitter::Base.new(oauth)
end
private
def authorize
unless @authorized
oauth.authorize_from_access(@access_token, @access_secret)
end
@authorized = true
end
def authorize_from_console
request_token = oauth.request_token.token
request_secret = oauth.request_token.secret
puts "Request token => #{request_token}"
puts "Request secret => #{request_secret}"
puts "Authentication URL => #{oauth.request_token.authorize_url}"
print "Provide the PIN that Twitter gave you here: "
pin = STDIN.gets.chomp
oauth.authorize_from_request(request_token,request_secret,pin)
puts "Access token => #{oauth.access_token.token}"
puts "Access secret => #{oauth.access_token.secret}"
end
def oauth
@oauth ||= Twitter::OAuth.new(CONSUMER_KEY, CONSUMER_SECRET)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment