Created
November 26, 2009 01:22
-
-
Save nogweii/243154 to your computer and use it in GitHub Desktop.
Attempt at a simple Twitter CLI OAuth sample
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
| #!/usr/bin/ruby | |
| require 'twitter' | |
| require 'pp' | |
| oauth = Twitter::OAuth.new('key', 'secret'); | |
| rtoken = oauth.request_token.token | |
| rsecret = oauth.request_token.secret | |
| puts "> redirecting you to twitter to authorize..." | |
| puts ">> #{oauth.request_token.authorize_url}" | |
| print "> what was the PIN twitter provided you with? " | |
| pin = gets.chomp | |
| begin | |
| oauth.authorize_from_request(rtoken, rsecret, pin) | |
| twitter = Twitter::Base.new(oauth) | |
| twitter.user_timeline.each do |tweet| | |
| puts "#{tweet.user.screen_name}: #{tweet.text}" | |
| end | |
| rescue OAuth::Unauthorized | |
| puts "> FAIL!" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment