lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


After much investigation, I think I made some progress. It looks like I have
to include "Content-Type" and "Content-Length" in the header for the POST
request. So now instead of getting "{"error":"Invalid command."}", I get
"{"error":"Invalid API key/secret pair."}".

The hmac-sha512 digest is computed from the secret and post data request
sent to the server. Since I get the same hash as in python, I'm guessing
somehow the server end isn't getting the post data correctly.

Anyone have any ideas?

Here's the updated script so far:

  http://pastebin.com/xBVNbucT

The main change is in the header table:

  headers =
  {
    Sign = signature,
    Key = key,
    ["Content-Type"] = "application/x-www-form-urlencoded",
    ["Content-Length"] = #post_data
  },

As a sidenote, I've manually constructed the POST request using the chrome
app addon called "POSTMAN" as a test. The query successfully goes through
when using the following 3 header-fields: Key, Sign, Content-Type with
content type being "application/x-www-form-urlencoded". Filling the body of
the request with "nonce=1399116375497&command=returnBalances" in raw form.

So I'm stumped as to why luasocket+luasec doesn't want to work.



--
View this message in context: http://lua.2524044.n2.nabble.com/Luasocket-Luasec-not-retrieving-data-from-https-api-tp7659651p7659665.html
Sent from the Lua-l mailing list archive at Nabble.com.