Skip to content

Instantly share code, notes, and snippets.

@alaingoldman
Created February 21, 2014 13:23
Show Gist options
  • Save alaingoldman/9134138 to your computer and use it in GitHub Desktop.
Save alaingoldman/9134138 to your computer and use it in GitHub Desktop.
@API_KEY = 'asdfghj'
@API_SECRET = 'asdfghjklfrgh'
def get_http(url, body=nil)
@nonce = (Time.now.to_f * 1e6).to_i
@message = @nonce.to_s + url + body.to_s
@signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha256'), @API_SECRET, @message)
@headers = {"ACCESS_KEY" => @API_KEY, "ACCESS_SIGNATURE" => @signature, "ACCESS_NONCE" => @nonce}
begin
if body.nil?
RestClient.get(url, @headers)
else
RestClient.post(url, body, @headers)
end
rescue => e
puts e
e.response
end
end
button = {
:name => 'meep',
:type => 'buy_now',
:description => "Coins you're willing to sell with meep.",
:style => 'none',
:custom => @user.token,
:custom_secure => true,
:variable_price => true,
:price_string => "0.400",
:price_currency_iso => 'BTC',
:text => "Send to us",
:choose_price => true,
:auto_redirect => true,
:callback_url => "#{root_url}?ssecret=85HgugcNRqg9"
}
response = get_http('https://coinbase.com/api/v1/buttons', button)
ERROR: ACCESS_SIGNATURE does not validate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment