2017-08-06 14 views
5

के साथ योबिट टैपि समस्याएं मैं अपने लिए सरल एप्लिकेशन लिखने की कोशिश कर रहा हूं और जब मैं getInfo विधि को कॉल करने का प्रयास करता हूं तो मुझे हमेशा प्रतिक्रिया में त्रुटि मिलती है। कुंजी, साइन, विधि या nonce गलत है। मुझे कई उदाहरण मिले लेकिन मुझे अभी भी मेरे कोड में गलती नहीं मिल रही है। क्या कोई मेरी मदद कर सकता है?स्वैच्छिकता

कोड हिटबेटसी के लिए ठीक काम करता है। मुझे पता है कि योबिट थोड़ा अलग है लेकिन मुझे लगता है कि मैंने इसे समायोजित किया है।

मेरे कोड:

Protected Shared Function readStrings(signatureheader As String, host As String, pathandQuery As String, post As String, secret As String, hasher As System.Security.Cryptography.HMAC, otherHeaders As Tuple(Of String, String)()) As String 
    'apikey=98998BEEB8796455044F02E4864984F4 
    'secret=44b7659167ffc38bb34fa35b5c816cf5 
    hasher.Key = exchanges.getBytes(secret) 
    Dim url = host + pathandQuery ' url = "https://yobit.net/tapi/" 
    Dim wc = New CookieAwareWebClient() 
    Dim sigHash2 = "" 

    If post = "" Then 
     sigHash2 = CalculateSignature2(pathandQuery, hasher) 
    Else 
     'post = "method=getInfo&nonce=636431012620" 
     sigHash2 = CalculateSignature2(post, hasher) 'sighash2= "ece0a3c4af0c68dedb1f840d0aef0fd5fb9fc5e808105c4e6590aa39f4643679af5da52b97d595cd2277642eb27b8a357793082007abe1a3bab8de8df24f80d2" 
    End If 

    wc.Headers.Add(signatureheader, sigHash2) ' SignatureHeader ="Sign" 

    Dim response = "" 

    For Each oh In otherHeaders ' otherHeaders =(0) {(Key, 98998BEEB8796455044F02E4864984F4)} System.Tuple(Of String, String) 
     wc.Headers.Add(oh.Item1, oh.Item2) 
    Next 

    '-  wc.Headers {Sign: ece0a3c4af0c68dedb1f840d0aef0fd5fb9fc5e808105c4e6590aa39f4643679af5da52b97d595cd2277642eb27b8a357793082007abe1a3bab8de8df24f80d2 Key: 98998BEEB8796455044F02E4864984F4 } System.Net.WebHeaderCollection 
    'url = "https://yobit.net/tapi/" 
    'post = "method=getInfo&nonce=636431012620" 

    If post = "" Then 
     response = wc.DownloadString(url) 
    Else 
     response = wc.UploadString(url, post) 'response =  response "{"success":0,"error":"invalid key, sign, method or nonce"}" String 

    End If 


    Return response 
End Function 

कोड hitbtc के लिए सफलतापूर्वक परीक्षण किया गया है।

तो क्रिप्टो भाग सही है। मैं यह मानसिक स्वास्थ्य की जांच के लिए पूर्णता

Protected Shared Function CalculateSignature2(text As String, hasher As System.Security.Cryptography.HMAC) As String 
    Dim siginhash = hasher.ComputeHash(exchanges.getBytes(text)) 
    Dim sighash = exchanges.getString(siginhash) 
    Return sighash 
End Function 

तो,

के लिए वैसे भी यहाँ रखा

इस कोड काम करता है

Public Overrides Sub readbalances() 
    Dim response = readStrings("X-Signature", "https://api.hitbtc.com", "/api/1/trading/balance?nonce=" + exchanges.getNonce().ToString + "&apikey=" + _apiKey, "", _secret, New System.Security.Cryptography.HMACSHA512(), {}) 


End Sub 

साथ yobit चीजें अलग हैं। मुझे पाने के बजाय पोस्ट का उपयोग करना पड़ा। मुझे और हेडर जोड़ना पड़ा। हालांकि, मुझे लगता है कि मैंने इसे ठीक कर दिया है।

यह काम नहीं करता है।

yobit एपीआई के लिए अजगर समारोह इस मैं सिर्फ इतना है कि अनुवाद करने के लिए vb.net जो मुझे लगता है कि मैं ईमानदारी से किया है

API Call Authentication in Python (Working PHP example)

मुझे लगता है कि गलती के आसपास यहां

request_url = "https://yobit.net/tapi"; 
request_body = "method=TradeHistory&pair=ltc_btc&nonce=123"; 
signature = hmac_sha512(request_body,yobit_secret); 
http_headers = { 
    "Content-Type":"application/x-www-form-urlencoded", 
    "Key":yobit_public_key, 
    "Sign":signature 
} 

response = http_post_request(request_url,request_body,http_headers); 
result = json_decode(response.text); 
है की जरूरत है

वहां जो सामान मैंने कॉपी किया है वह है विधि = getInfo & nonce = 636431012620 जो मैंने पोस्ट में रखा है।

तो यह सही लगता है।

+0

मैं तुम्हें यूआरएल पर विधि जोड़ नहीं लगता कि एक के रूप में New Tuple(Of String, String)("Content-Type", "application/x-www-form-urlencoded") जोड़ा है। आपको पोस्ट कमांड का उपयोग करना चाहिए। –

+0

आपके उत्तर के लिए धन्यवाद। तुम सही हो। समस्या गलत अनुरोध के साथ थी। मुझे पहले से ही समाधान मिला है – Alex

उत्तर

1

ऐसा लगता है कि यह काम करता है।

मैं सिर्फ

post = "method=getInfo&nonce=636431012620 

अस्थायी रूप से है कि बड़ा नहीं होना चाहिए, ताकि वह बीच 0 2^

को 31 तो इस त्रुटि है अस्थायी रूप से बदलने की जरूरत है। अधिक से अधिक यह होना चाहिए

इसके अलावा, हालांकि दस्तावेज नहीं है, मैं

सामग्री प्रकार जोड़ना होगा शीर्ष लेख में से एक के रूप में।यह अंतिम समाधान

Dim nonce = exchanges.getNonce().ToString 
    Dim content = hashObject("", nonce, "method=getInfo&nonce=") 
    Dim sighash = computeSig(content) 
    Dim result = CookieAwareWebClient.downloadString1("https://yobit.net/tapi/", content, {New Tuple(Of String, String)("Key", _apiKey), New Tuple(Of String, String)("Sign", sighash), New Tuple(Of String, String)("Content-Type", "application/x-www-form-urlencoded")}) 

तो मैं हेडर

Protected Overridable Function computeSig(content As String) As String 
    Dim hasher = New System.Security.Cryptography.HMACSHA512(System.Text.Encoding.UTF8.GetBytes(_secret)) 
    Return CalculateSignature2(content, hasher) 
End Function 

Public Shared Function CalculateSignature2(content As String, hasher As System.Security.Cryptography.HMAC) As String 
    Dim siginhash = hasher.ComputeHash(System.Text.Encoding.UTF8.GetBytes(content)) 
    Dim sighash = exchanges.getString(siginhash) 'convert bytes to string 
    Return sighash 
End Function 

Public Shared Function downloadString1(url As String, post As String, otherHeaders As Tuple(Of String, String)()) As String 
    Dim wc = New CookieAwareWebClient() 
    For Each oh In otherHeaders 
     wc.Headers.Add(oh.Item1, oh.Item2) 
    Next 

    Dim response = String.Empty 

    Try 
     If post = "" Then 
      response = wc.DownloadString(url) 
     Else 
      response = wc.UploadString(url, post) 
     End If 
    Catch ex As Exception 
     Dim a = 1 
    End Try 

    Return response 
End Function 

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^