Author

Topic: hilfe bei bitfinex api.... kleines problem... (Read 2629 times)

legendary
Activity: 965
Merit: 1000
August 13, 2014, 04:34:54 PM
#4
Vermutlich wird Dir bei vb.net kaum einer helfen können. Würde eher mal ein Log posten, während er einen Request versucht, oder so.
legendary
Activity: 966
Merit: 1000
push
legendary
Activity: 966
Merit: 1000
push
legendary
Activity: 966
Merit: 1000
hey...

hänge hier an einem kleinen problem mit der bitfinex api....

Bei der Methode: GET, mit api_path = "/v1/symbols", Funktioniert es.

GET -> läuft

POST -> leider nicht, gibt nur fehler 400 ->
Fehler: Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.

würde mich über tipps oder hilfe sehr freuen...

Code:
VB.NET-Quellcode

    ​
    Public Shared api_url As String = "https://api.bitfinex.com/"
    Public Shared api_key As String = "CodeCodeCode"
    Public Shared api_secret As String ="CodeCodeCode"
    Public Shared api_path As String = "/v1/symbols"
    'Public Shared api_path As String = "/v1/account_infos"
    Public Function check_balance()
    Dim payLoadobject As New PayLoad()
    Dim MySerializer As JavaScriptSerializer = New JavaScriptSerializer()
    Dim payloadJson As String = MySerializer.Serialize(payLoadobject)
    Dim payload As String = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(payloadJson))
    Dim encoding As New System.Text.ASCIIEncoding()
    Dim getmessageBytes As Byte() = encoding.GetBytes(payload)
    Dim secretByte As Byte() = encoding.GetBytes(api_secret)
    Dim gethmacsha384 As New HMACSHA384(secretByte)
    Dim hashmessage As Byte() = gethmacsha384.ComputeHash(getmessageBytes)
    Dim finalString As New StringBuilder()
    For i As Integer = 0 To hashmessage.Length - 1
    finalString.Append(hashmessage(i).ToString("X2"))
    Next
    Dim SIGNATURE As String = finalString.ToString()
    Dim request As HttpWebRequest
    Dim nurl As String = api_url + api_path
    Dim address As Uri = New Uri(nurl)
    request = DirectCast(WebRequest.Create(address), HttpWebRequest)
    request.Accept = True
    request.Method = "GET" 'POST or GET
    request.Headers("X-BFX-APIKEY") = api_key
    request.Headers("X-BFX-PAYLOAD") = payload
    request.Headers("X-BFX-SIGNATURE") = SIGNATURE
    request.AllowAutoRedirect = True
    request.AllowWriteStreamBuffering = True
    request.KeepAlive = True
    Dim response As HttpWebResponse = Nothing
    Dim reader As StreamReader = Nothing
    Dim result As String = Nothing
    Try
    response = DirectCast(request.GetResponse(), HttpWebResponse)
    reader = New StreamReader(response.GetResponseStream())
    result = reader.ReadToEnd()
    Catch ex As Exception
    Return ex.Message.ToString()
    Finally
    If Not response Is Nothing Then response.Close()
    End Try
    Return result
    End Function
    Public Class coptions
    Public hostname As String = "https://api.bitfinex.com/"
    Public port As String = "443"
    Public path As String
    Public method As String = "GET" 'POST OR GET
    End Class
    Public Class PayLoad
    Public request As String = api_path
    Public nonce As String = Convert.ToInt64((DateTime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds)
    Public options As New coptions
    End Class

Jump to: