Skip to content

Instantly share code, notes, and snippets.

@keikubo
Created April 6, 2013 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keikubo/5327601 to your computer and use it in GitHub Desktop.
Save keikubo/5327601 to your computer and use it in GitHub Desktop.
Ruby1.8.5でWebPayのRest APIを使う例。
#!/usr/bin/env ruby
require 'net/https'
require 'uri'
require 'rubygems'
require 'json'
url = URI.parse('https://api.webpay.jp/v1/charges/ch_WO14ib0ANJiSHn')
req = Net::HTTP::Get.new(url.path)
req.basic_auth 'vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE', ''
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
https.start do |h|
res = h.request(req)
obj = JSON.parse(res.body)
puts obj['id']
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment