我一直在尝试验证bitstamp api,但是我继续收到以下错误:
"{\"error\": \"Missing key, signature and nonce parameters\"}"
我写的代码如下:
let nounce = System.DateTime.Today.Ticks
let hexdigest (bytes : byte[]) =
let sb = System.Text.StringBuilder()
bytes |> Array.iter (fun b -> b.ToString("X2") |> sb.Append |> ignore)
string sb
let signature =
use hmac = new HMACSHA256(System.Text.Encoding.ASCII.GetBytes(stampsecret))
hmac.ComputeHash(mes)
|> hexdigest
我正在使用以下内容呼叫网站:
let ordersBTCbuy()=
Http.Request("https://www.bitstamp.net/api/buy", meth="Post", query=["key", stampkey; "signature", signature.ToLower(); "nonce", string(nounce); "amount", "1"; "price", string(convertB)])
可在此处找到对API的引用:https://www.bitstamp.net/api/
更新我已将网址更改为:
let ordersBTCbuy()= Http.Request(“https://www.bitstamp.net/api/buy/”,meth =“Post”,query = [“key”,stampkey;“signature”,signature.ToLower();“nonce”,string(nounce);“amount”, “1”;“价格”,字符串(convertB)])
我的新问题现在是签名我的表示长度为64个字符大写,但我似乎仍然有错误。
答案 0 :(得分:1)
创建POST
请求时。你的键值对需要进入体内。
要使用FSharp数据执行此操作,请执行以下操作:
let postBody = FormValues([ "key", stampkey; "signature", signature.ToLower(); "nonce", string(nounce); "amount", "1"; "price", string(convertB)])
let ordersBTCbuy()=
Http.Request("https://www.bitstamp.net/api/buy", httpMethod="Post", body=postBody)