Title: [C#] Could use some help with authenticated requests with MtGox API v2 Post by: Effayy on May 14, 2013, 03:54:15 AM For fun (and to teach myself some C#) I've been integrating someone's C# socket.io class with MtGox's API. I can currently recieve and parse all the public information (trades, depth, ticker, lag). That's all peachy. My issue is with authenticated requests. I've been trying to follow along and convert the code example listed at https://en.bitcoin.it/wiki/MtGox/API/Streaming. Here's the part I'm interested in replicating:
Code: $nonce = explode(' ', microtime(false)); Essentially what happens is once I try to make the authenticated call, my socket immediately drops connection. I do have try/catch all over the place (including some added to the socket.io and websocket classes I aquired) but it doesn't seem to be causing any errors, and no op:remark comes back from the server. It just dies. Poof. gonzo. Dead as a doornail. So now in order to try and reclaim what little sanity I may have left, I'm asking for some advice. Yes, I do realize I could just flip to another language and all is good, but I'm trying to pick up C# for my day-job. I believe that my JSON is well-formed, but I think my issue with the code lies within the encoding/hashing algorithms. The call I'm specifically trying to make is to "private/info". Here is what I have for each encoded/decoded/hashed value: $ID: Code: string nonce = DateTime.Now.Ticks.ToString(); $SIGN: Code: protected string EncodeSign(string query) $KEY: Code: string key = HexToString(apiKey.Replace("-", "")); $QUERY (the pack() line, not the json_encode line) Code: encQuery = key + encQuery + sb.ToString(); //sb is a StringBuilder object containing the inner query (equivalent of the $query = json_encode($query); line in the PHP example) Does anyone see an issue with my encoding off the top of their head? Any help is appreciated. |