Title: Bter API in C# - Bounty Offered Post by: AstralAcc3ss on October 04, 2014, 03:56:01 AM I've been stuck on this forever now. I can't for the life figure out what I am doing wrong. I'm just trying to make a simple trade api query using BTER api. Here is my code. Bare with me, I'm fairly new to C#.
Ill give whoever shows me the way a small reward ;) If im doing something wrong or improper let me know please, so I can learn and fix it :x string bterkey = "xxx"; string btersecret= "xxx"; string Url; WebClient request = new WebClient(); DateTime dtCurTime = DateTime.Now; DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 8:00:00 AM"); TimeSpan ts = dtCurTime.Subtract(dtEpochStartTime); long epochtime; epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds); Url = "https://data.bter.com/api/1/private/orderlist?nonce=" + epochtime; var dataStr = Url; request.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); request.Headers.Add("key", bterkey); var hmac = new HMACSHA512(Encoding.ASCII.GetBytes(btersecret)); var messagebyte = Encoding.ASCII.GetBytes(Url); var hashmessage = hmac.ComputeHash(messagebyte); var sign = BitConverter.ToString(hashmessage).Replace("-", ""); request.Headers.Add("sign", sign); byte[] bret = request.UploadData(Url, "post", System.Text.Encoding.ASCII.GetBytes("")); string sret = System.Text.Encoding.ASCII.GetString(bret); Title: Re: Bter API in C# - Bounty Offered Post by: szmarco on October 04, 2014, 08:05:10 AM Why don't you send a message to a staff of this website,just like this https://bitcointalk.org/index.php?action=profile;u=336981
She is a customer service girl. I believe she will transfer your problem to technicman. Title: Re: Bter API in C# - Bounty Offered Post by: AstralAcc3ss on October 04, 2014, 02:08:37 PM Why don't you send a message to a staff of this website,just like this https://bitcointalk.org/index.php?action=profile;u=336981 She is a customer service girl. I believe she will transfer your problem to technicman. I actually submitted a ticket, and they told me to refer to the PHP example on the bottom of the page. Which did absolutely nothing to help me :( Title: Re: Bter API in C# - Bounty Offered Post by: AstralAcc3ss on October 04, 2014, 11:44:34 PM bump?
Title: Re: Bter API in C# - Bounty Offered Post by: amacar on October 05, 2014, 09:43:15 AM Code: Url = "https://data.bter.com/api/1/private/orderlist?nonce=" + epochtime; In their api is written that there is no parameters for "orderlist", so don't know why are you using Code: ?nonce=" + epochtime Title: Re: Bter API in C# - Bounty Offered Post by: AstralAcc3ss on October 05, 2014, 05:26:51 PM i'v seen example they were feeding nonce as parameters, and i was testing various ways trying to get it to work. the nonce doesn't matter, It still doesn't work.
Title: Re: Bter API in C# - Bounty Offered Post by: amacar on October 05, 2014, 06:02:48 PM I was referring to this image
https://i.imgur.com/9kF9JuA.png Anyway if I have time I will try to check code and tell you if I would have more luck than you. Title: Re: Bter API in C# - Bounty Offered Post by: amacar on October 05, 2014, 10:58:48 PM Ok I tried something, but don't have any funds on bter so I can't really test, but when I run it I get message Success.
Here is function for bter query Code: string bter_query(string path, NameValueCollection req, string key, string secret) And you can call it like that: Code: MessageBox.Show(bter_query(@"1/private/orderlist", new NameValueCollection(), textBoxApiKey.Text, textBoxApiSecret.Text)); Result: https://i.imgur.com/nLiPXkL.png Title: Re: Bter API in C# - Bounty Offered Post by: amacar on October 05, 2014, 11:23:11 PM Just edited query function so it should now behave the same as their php function in api example. Again I can't test it due to no funds but I got message that order number is incorrect, so I assume that it is ok.
function: Code: string bter_query(string path, NameValueCollection req, string key, string secret) Run it like that: Code: MessageBox.Show(bter_query(@"1/private/orderlist", new NameValueCollection(), textBoxApiKey.Text, textBoxApiSecret.Text)); Title: Re: Bter API in C# - Bounty Offered Post by: AstralAcc3ss on October 06, 2014, 06:03:53 PM Just edited query function so it should now behave the same as their php function in api example. Again I can't test it due to no funds but I got message that order number is incorrect, so I assume that it is ok. function: Code: string bter_query(string path, NameValueCollection req, string key, string secret) Run it like that: Code: MessageBox.Show(bter_query(@"1/private/orderlist", new NameValueCollection(), textBoxApiKey.Text, textBoxApiSecret.Text)); Thanks it works. Ill review the code to see what I was doing wrong. Please post your BTC Addr. Title: Re: Bter API in C# - Bounty Offered Post by: amacar on October 06, 2014, 06:13:56 PM Here is my address: 1PdHRDrRxBsohPRJMxTa5cVLNriEbJUhdP
Thank you :) Title: Re: Bter API in C# - Bounty Offered Post by: AstralAcc3ss on October 07, 2014, 05:36:36 PM Sent, sorry took longer than you expected. Not much, but it's what I can spare ;)
Title: Re: Bter API in C# - Bounty Offered Post by: amacar on October 07, 2014, 05:53:43 PM I appreciate all amounts, so thank you :)
It was also good exercise for me as I have never worked with APIs. Title: Re: Bter API in C# - Bounty Offered Post by: amacar on October 28, 2014, 08:56:19 AM I also made same API call in C# for bittrex if someone needs.
Code: string bittrex_query(string path, NameValueCollection req, string key, string secret) And call it like that: Code: MessageBox.Show(bittrex_query(@"account/getbalances", new NameValueCollection(), textBoxAPIKEY.Text, textBoxSECRET.Text)); |