Created
September 10, 2013 12:45
-
-
Save Olefine/6508913 to your computer and use it in GitHub Desktop.
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' | |
# Change the following values to those provided on dev.twitter.com | |
# The consumer key identifies the application making the request. | |
# The access token identifies the user making the request. | |
consumer_key = OAuth::Consumer.new( | |
"miJSmFqLUEVrY8huJJReZw", | |
"5ilaj6E2jFFxsd0zdA1wsKqc9dDv7OnjTR86206poQk") | |
access_token = OAuth::Token.new( | |
"408279263-NAVu3INQ6NZyjQeAnBwtZzVP457NuzEordtaw3JK", | |
"6O1G0RmdOYEWKImeuqboyB2bao1mQGZA5dQSKMLs") | |
# All requests will be sent to this server. | |
baseurl = "https://api.twitter.com" | |
# The verify credentials endpoint returns a 200 status if | |
# the request is signed correctly. | |
address = URI("#{baseurl}/1.1/account/verify_credentials.json") | |
# Set up Net::HTTP to use SSL, which is required by Twitter. | |
http = Net::HTTP.new address.host, address.port | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
# Build the request and authorize it with OAuth. | |
request = Net::HTTP::Get.new address.request_uri | |
request.oauth! http, consumer_key, access_token | |
# Issue the request and return the response. | |
http.start | |
response = http.request request | |
puts "The response status was #{response.code}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment