Created
June 18, 2012 06:51
-
-
Save Pcushing/2947197 to your computer and use it in GitHub Desktop.
Login to Twitter, follow a single user and print all twitter client methods for future reference
This file contains 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 'rubygems' | |
require 'oauth' | |
require 'twitter' | |
consumer_key = 'HIDDEN' | |
consumer_secret = 'HIDDEN' | |
@consumer = OAuth::Consumer.new( | |
consumer_key, | |
consumer_secret, | |
{:site => 'http://twitter.com'} | |
) | |
# Get the request token & PIN | |
@request_token = @consumer.get_request_token | |
puts "You should probably go to #{ @request_token.authorize_url }. Go on. I'll wait." | |
puts "When you're ready, enter the number they give you: " | |
pin = STDIN.readline.chomp #can be done with gets.chomp | |
# Get the access token that tells us the user logged in and agreed to our access | |
@access_token = @request_token.get_access_token(:oauth_verifier => pin) | |
puts "The access token is #{ @access_token.token }" | |
puts "The access secret is #{ @access_token.secret }" | |
# Let's authenticate you, user. | |
Twitter.configure do |config| | |
config.consumer_key = consumer_key | |
config.consumer_secret = consumer_secret | |
config.oauth_token = @access_token.token | |
config.oauth_token_secret = @access_token.secret | |
end | |
# Lets' do something. | |
client = Twitter::Client.new | |
client.friendship_create("Pcushing") | |
puts "#{ client.methods.sort }" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment