Migrated from Redmine #112 | Author: Robert Hamilton
Status: New | Priority: Normal | Created: 2018-02-18
I asked for some help with sample VB6 code and the response was a rather unhelpful “we don’t have any”. Well… after tons of work and lots of trial and error I have some sample code for you. Please feel free to use it as you see fit.
@
Sub VB6Sample()
Dim Q As String
Q = Chr$(34)
Company$ = “YourCompanyHere”
AuthKey$ = “YourAuthKeyHere”
CompanyID$ = “1”
Set oXMLHTTP = New WinHttp.WinHttpRequest
Payload$ = “{” & Q & “jsonrpc” & Q & “:” & Q & “2.0” & Q & “,” & Q & “method” & Q & “:” & Q & “getToken” & Q & “,” & Q & “params” & Q & “:[” & Q
Payload$ = Payload$ & Company$ & Q & “,” & Q & AuthKey$
Payload$ = Payload$ & Q & “],” & Q & “id” & Q & “:” & CompanyID$ & “}”
PayloadLength$ = Trim(Str(Len(Payload$)))
Call oXMLHTTP.Open(“POST”, “http://user-api.simplybook.me/login”, False)
Call oXMLHTTP.SetRequestHeader(“Accept”, “application/json, text/javascript, /; q=0.01”)
Call oXMLHTTP.SetRequestHeader(“Accept-Encoding”, “gzip, deflate”)
Call oXMLHTTP.SetRequestHeader(“Accept-Language”, “en-US,en;q=0.9”)
Call oXMLHTTP.SetRequestHeader(“Connection”, “keep-alive”)
Call oXMLHTTP.SetRequestHeader(“Content-Length”, Q & PayloadLength$ & Q)
Call oXMLHTTP.SetRequestHeader(“Content-Type”, “application/json”)
Call oXMLHTTP.SetRequestHeader(“DNT”, “1”)
Call oXMLHTTP.SetRequestHeader(“Host”, “user-api.simplybook.me”)
Call oXMLHTTP.Send(Payload$)
Response$ = oXMLHTTP.ResponseText
MsgBox Response$
End Sub
@