This is what I am having trouble understanding and doing.
I need to add a header called sign with the query's POST data signed by my key's "secret" according to the HMAC-SHA512 method. What is my query's post data? And how can I find it so that I can encrypt it and send it as a header.
These are my parameters: "command" => "returnBalances", "nonce" => Time.now.to_i
Please let me know:
Thank you people let me know.
I answered your question more completely here, in the context of the Poloniex exchange:
To answer your specific questions from this post:
POST data simply means the body of your request. This could be JSON, plain text, form data, etc. In cases where a specific format (i.e. JSON) isn't mentioned, POST data probably refers to POST form data (Content-Type: application/x-www-form-urlencoded
). This is how data submitted from a web form is formatted and indeed that appears to be what Poloniex is looking for.
x-www-form-urlencoded
data can be produced like this in Ruby:
form_data = URI.encode_www_form({:command => 'returnBalances', :nonce => Time.now.to_i * 1000 })
puts form_data
command=returnBalances&nonce=1447537613000
Mozilla Developer's Network link on POST form data.
HMAC digest produces a unique string based on a secret key and the data provided. In Ruby, you can produce an HMAC digest like so:
OpenSSL::HMAC.hexdigest( 'sha512', secret, form_data)