Announcement

Collapse
No announcement yet.

Http.POST problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Http.POST problem

    Hi people, long time no see. I am trying to quickly build a small bot for trading altcoins on Poloniex.com but I am having trouble posting data to the site and retrieving information. The part that I am interested is this:

    As stated on their site:

    All calls to the trading API are sent via HTTP POST to https://poloniex.com/tradingApi and must contain the following headers:

    Key - Your API key.
    Sign - The query's POST data signed by your key's "secret" according to the HMAC-SHA512 method.

    Additionally, all queries must include a "nonce" POST parameter. The nonce parameter is an integer which must always be greater than the previous nonce used.
    and also the command that I want to send is "returnBalances"

    So here is my script:

    Code:
    local Key = "TZX6L4AH-7UQ2P6I1-LR0SPQJX-OLZULB64"
    local Sign = "1c0a40253e52f9aeab934f0e617ebd80bad16235cfe7271c1a17d8f54ee26d39b001b6ec9e8bf139295052c2c4a1f36b0e34276c5675be341801b0ec187b0589"
    local targetURL = "https://poloniex.com/tradingApi"
    
    
    
    local strUrlArguments = "?command=%s&nonce=%s"
    local strValues = string.format(strUrlArguments,"returnBalances","203");
    
    
    local PoloniexCal = luacom.CreateObject("WinHttp.WinHttpRequest.5.1");
    
    if (PoloniexCal ~= nil) then
    
    PoloniexCal:Open("POST", targetURL..strValues, 0)
    PoloniexCal:SetRequestHeader("Key", Key );
    PoloniexCal:SetRequestHeader("Sign", Sign );
    PoloniexCal:Send();
    
    if (PoloniexCal.Status == 200) then
    
    local result = PoloniexCal.ResponseText
    Dialog.Message("Google's Response", result);
    
    else
    
    Dialog.Message("Error", "Failed To Complete Http Request");
    
    end
    
    PoloniexCal = nil;
    collectgarbage();
    
    end
    The return I get is
    {"error":"Invalid command."}
    Don't quite know what to do next. Hope someone can help me. Thanks in advance
Working...
X
😀
🥰
🤢
😎
😡
👍
👎