Created
September 1, 2010 02:09
-
-
Save dpickett/560110 to your computer and use it in GitHub Desktop.
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
| 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