(AutoIt) qa.factura1.com.co Obtain Auth Token
Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co Note: This example requires Chilkat v11.0.0 or greater.
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; Build the following JSON
; {
; "password": "MY_PASSWORD",
; "username": "MY_USERNAME"
; }
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.EmitCompact = False
$oJson.UpdateString("password","MY_PASSWORD")
$oJson.UpdateString("username","MY_USERNAME")
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST","https://qa.factura1.com.co/v2/auth",$oJson,"application/json",$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oJsonResp = ObjCreate("Chilkat.JsonObject")
$oJsonResp.EmitCompact = False
$oJsonResp.Load($oResp.BodyStr)
ConsoleWrite($oJsonResp.Emit() & @CRLF)
ConsoleWrite("Access token: " & $oJsonResp.StringOf("token") & @CRLF)
|