C-patex api 说:签名无效
我正在尝试为 Pascalabc 上的 c-patex 交换创建一个加密机器人。我被困在使用密钥和秘密密钥的私人请求上。我收到错误 - {"error":{"code":2005,"message":"签名不正确。"}}
这是我的代码:
function GetOrders.TGetOrders.GetOrders: string;
begin
var hmac := new HMACSHA256(Encoding.UTF8.GetBytes('xxx'));
var timestapm := (System.IO.StreamReader.Create(System.Net.WebRequest.CreateHttp('https://c-patex.com//api/v2/timestamp.json').GetResponse.GetResponseStream).ReadToEnd.ToBigInteger * 1000).ToString;
var sigstring := 'GET|/api/v2/orders|access_key=yyy&tonce=' + timestapm.ToBigInteger / 100 + '&market=compdoge';
var compute := hmac.ComputeHash(Encoding.UTF8.GetBytes(sigstring), 0, Encoding.UTF8.GetBytes(sigstring).Length);
var signature := System.BitConverter.ToString(compute).Replace('-', string.Empty).ToLower();
var reqstring := 'https://c-patex.com//api/v2/orders?access_key=6BckEAz52cOwpx1gfT0nByhLxkNF8uzzTFdzT8Oa' +
'&market=compdoge' +
'&signature=' + signature +
'&tonce=' + timestapm;
Writeln(reqstring);
try
var request := System.Net.WebClient.Create;
var data := request.DownloadData(reqstring);
except
on ex: System.Net.WebException do
begin
var Response := ex.Response;
var stream := Response.GetResponseStream;
var Reader := new System.IO.BinaryReader(Stream);
var res := Reader.ReadBytes(stream.Length);
var chararr := Encoding.UTF8.GetChars(res);
var output := System.string.Create(chararr);
Writeln(output);
end;
end;
end;
end.
有人使用过此交易所的 api 吗?你有遇到过类似的问题吗? 提前致谢。
I am trying to create a crypto bot for the c-patex exchange on Pascalabc. I'm stuck on private requests using a key and a secret key. I get an error - {"error":{"code":2005,"message":"Signature is incorrect."}}
This is my code:
function GetOrders.TGetOrders.GetOrders: string;
begin
var hmac := new HMACSHA256(Encoding.UTF8.GetBytes('xxx'));
var timestapm := (System.IO.StreamReader.Create(System.Net.WebRequest.CreateHttp('https://c-patex.com//api/v2/timestamp.json').GetResponse.GetResponseStream).ReadToEnd.ToBigInteger * 1000).ToString;
var sigstring := 'GET|/api/v2/orders|access_key=yyy&tonce=' + timestapm.ToBigInteger / 100 + '&market=compdoge';
var compute := hmac.ComputeHash(Encoding.UTF8.GetBytes(sigstring), 0, Encoding.UTF8.GetBytes(sigstring).Length);
var signature := System.BitConverter.ToString(compute).Replace('-', string.Empty).ToLower();
var reqstring := 'https://c-patex.com//api/v2/orders?access_key=6BckEAz52cOwpx1gfT0nByhLxkNF8uzzTFdzT8Oa' +
'&market=compdoge' +
'&signature=' + signature +
'&tonce=' + timestapm;
Writeln(reqstring);
try
var request := System.Net.WebClient.Create;
var data := request.DownloadData(reqstring);
except
on ex: System.Net.WebException do
begin
var Response := ex.Response;
var stream := Response.GetResponseStream;
var Reader := new System.IO.BinaryReader(Stream);
var res := Reader.ReadBytes(stream.Length);
var chararr := Encoding.UTF8.GetChars(res);
var output := System.string.Create(chararr);
Writeln(output);
end;
end;
end;
end.
Has anyone worked with the api of this exchange? Have you had a similar problem?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题。问题出在 Unix 时间,因为我从延迟很大的服务器获取它。
var unixTime := System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds;
这段代码工作正常,因为它使用本地时间并将其转换为 Unix 毫秒
Im solved this. Problem was in Unix time, because i get it from server with big latensy.
var unixTime := System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds;
This code work fine, because it uses local time and converts it to Unix milliseconds