2015-05-26 127 views

回答

1

使用這種寶石:https://github.com/oauth-xx/oauth-ruby

安裝:

sudo gem install oauth

然後:

require 'oauth' 

KEY     = "YOUR_KEY" 
SECRET    = "YOUR_SECRET" 
URL     = "YOUR_API_URL" 
ENDPOINT    = "YOUR_ENDPOINT_URL" 


consumer = OAuth::Consumer.new(KEY, SECRET, {site: URL}) 
# for a post 
res = consumer.request(:post, ENDPOINT, nil, {}, {}) 
# for a get 
res = consumer.request(:post, ENDPOINT, nil, {}, {}) 

# display response 
puts res 
相關問題