Created
February 4, 2014 07:42
-
-
Save enocom/8799593 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 "net/http" | |
require "uri" | |
require "json" | |
require "openssl" | |
require "yaml" | |
OAUTH_TOKEN = "some token goes here" | |
uri = URI.parse("https://api.github.com/users/enocom/repos") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request["Accept"] = "application/json" | |
request["Authorization"] = "token #{OAUTH_TOKEN}" | |
response = http.request(request) | |
json_body = JSON.parse(response.body) | |
File.open("body_json", "w") { |f| f.write json_body.to_yaml } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment