我无法获得Bluetrade API私人函数调用工作

时间:2018-01-11 05:53:09

标签: .net vb.net api

这是他们的PHP Examaple。您可以在https://bleutrade.com/help/API

找到整个API
$apikey = 'YOUR_API_KEY';
$apisecret = 'YOUR_API_SECRET';
$nonce = time();
$uri = 'https://bleutrade.com/api/v2/account/getbalances?                        
apikey='.$apikey.'&nonce='.$nonce;
$sign = hash_hmac('sha512',$uri,$apisecret);
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign)); // you can 
add the signature at the end of the uri if you prefer: &apisign=...
$execResult = curl_exec($ch);
$obj = json_decode($execResult);

以下是我的VB代码

    Dim sApiKey As String = "Enter API Key"
    Dim sApiSecret As String = "Enter API Secret Key"

    Dim sURI As String = "https://bleutrade.com/api/v2/account/getbalances?apikey=" + sApiKey
    Dim secretkey() As Byte = System.Text.Encoding.ASCII.GetBytes(sApiSecret)
    Dim uri() As Byte = System.Text.Encoding.ASCII.GetBytes(sURI)
    Dim myhmac As New HMACSHA512(secretkey)
    Dim bSign As Byte() = myhmac.ComputeHash(uri)
    Dim wrGETURL As WebRequest

    wrGETURL = WebRequest.Create(sURI)
    wrGETURL.Headers.Add("apsign:" & Convert.ToBase64String(bSign))
    Dim objStream As Stream
    objStream = wrGETURL.GetResponse.GetResponseStream()

    Dim objReader As New StreamReader(objStream)
    Dim sLine As String = ""
    Dim i As Integer = 0

    Do While Not sLine Is Nothing
        i += 1
        sLine = objReader.ReadLine
        If Not sLine Is Nothing Then

        End If
    Loop

我收到错误{“成功”:“错误”,“消息”:“无效的apikey或apisecret”,“结果”:[]}

我已经尝试了两次新的api密钥。

感谢万亿,无论你能用什么智慧。

1 个答案:

答案 0 :(得分:0)

wrGETURL.Headers.Add("apsign:" & Convert.ToBase64String(bSign))

尝试正确拼写apisign。另外,我认为您不需要对base64进行编码,而只需对其进行十六进制编码即可。