Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Dim job As HttpJob
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub PlaceOrder
job.Initialize("PlaceOrder", Me)
job.PostString("https://api.binance.com/api/v3/order", "symbol=BTCUSDT&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=10&recvWindow=5000×tamp=" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") & "Z&signature=" & GetSignature("symbol=BTCUSDT&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=10&recvWindow=5000×tamp=" & DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") & "Z"))
job.GetRequest.SetHeader("X-MBX-APIKEY", "YOUR_API_KEY")
End Sub
Private Sub JobDone(job As HttpJob)
If job.Success Then
Log("Response: " & job.GetString)
Else
Log("Error: " & job.ErrorMessage)
End If
End Sub
Sub GetSignature(query As String) As String
Dim hash As String
Dim message As String
message = query & "&secret=" & "YOUR_SECRET_KEY"
Return hash.HMAC_SHA256_HEX(message, "YOUR_SECRET_KEY")
End Sub