Skip to content

Instantly share code, notes, and snippets.

@Pcushing
Created June 18, 2012 06:51
Show Gist options
  • Save Pcushing/2947197 to your computer and use it in GitHub Desktop.
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
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