Created
March 20, 2013 17:18
-
-
Save michaelrkn/5206512 to your computer and use it in GitHub Desktop.
command line oauth for twitter
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
| require 'oauth' | |
| require 'launchy' | |
| CONSUMER_KEY = 'your_consumer_key' | |
| CONSUMER_SECRET = 'your_consumer_secret' | |
| CALLBACK_URL = 'oob' | |
| consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => "https://api.twitter.com/") | |
| request_token = consumer.get_request_token(:oauth_callback => CALLBACK_URL) | |
| puts 'To use TwitCommandLine, you need to grant access to the app.' | |
| puts 'Press enter to launch your web browser and grant access.' | |
| gets | |
| Launchy.open request_token.authorize_url(:oauth_callback => CALLBACK_URL) | |
| puts 'Now, copy the PIN below and press enter:' | |
| oauth_verifier = gets.chomp | |
| access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier) | |
| response = access_token.get('https://api.twitter.com/1.1/account/settings.json') | |
| response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment