Hello.
I made the corrections that you suggested. The error remains the same.
The IP restriction is disabled.
The new code with the suggested fixes is this
[CODE lang="b4x" highlight="55, 76, 78"]#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 300
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private TextAreaOut As TextArea
Private ButtonGet As Button
Private BaseURL As String
Private ApiSecret As String
Private ApiKey As String
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
BaseURL = "https://api.binance.com/api/"
ApiKey = "VmcKfcJ127jpeGUPAKXnHXJBTSF9iMfHUqptwEb1TCvSLwgNnCJ2BuWsdVwyhsbD"
ApiSecret = "xTFh2bqOydbMumZmWcV13ecPYFTHmZa5pg0Xp3rlay5Tyog2VBoEAJQToMURhU1E"
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub ButtonGet_Click
SendCommand("v3/account")
End Sub
private Sub SendCommand(ApiURL As String)
Dim Result As String
Dim TimeStamp As String = DateTime.Now
Dim Sign() As Byte = HashHmac(TimeStamp, ApiSecret)
If Sign.Length = 0 Then Return
Dim BConv As ByteConverter
Dim Signature As String = BConv.HexFromBytes(Sign).ToLowerCase 'convert to HEX
Dim URL As String = BaseURL & ApiURL & "?" & "timestamp=" & TimeStamp & "&" & "signature=" & Signature
Try
Dim j As HttpJob
j.Initialize("", Me)
j.Download(URL)
j.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
j.GetRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded")
j.GetRequest.SetHeader("X-MBX-APIKEY", ApiKey)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Result = j.GetString
Else
Result = j.ErrorMessage
End If
j.Release
Catch
Result = LastException.Message
End Try
MessageBox($"HttpJob result: ${Result}"$)
End Sub
Public Sub HashHmac(data As String, secret As String) As Byte()
Dim m As Mac 'm As Message Authentication Code
Dim kg As KeyGenerator 'kg As KeyGenerator
Dim Result() As Byte 'Result Sign
Try
kg.Initialize("HmacSHA256") 'initialize kg using HmacSHA512 algorithm
kg.KeyFromBytes(secret.GetBytes("UTF8")) 'encode string "secret" to an array of Bytes using UTF8
m.Initialise("HmacSHA256", kg.Key) 'initialize m using HmacSHA512 algorithm and the secret key
m.Update(data.GetBytes("UTF8")) 'encodes post data to an array of Bytes and loads it to be signed
Result = m.Sign 'sign the loaded data using the secret key, return the calc signature data
Catch
MessageBox($"HashHmac: ${LastException.Message}"$)
End Try
Return Result
End Sub
Public Sub MessageBox(Message As String)
TextAreaOut.Text = TextAreaOut.Text & CRLF & Message
End Sub[/CODE]
I attach project with the implemented suggestions.
Thanks.