AutoIt
AutoIt
effectconnect Read Orderlist
See more effectconnect Examples
Get a set of orders filtered by the parameters in the XML payload.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
Local $sFullUri = "https://submit.effectconnect.com/orderlist"
Local $sUri = "/orderlist"
Local $sApiVersion = "2.0"
$oHttp = ObjCreate("Chilkat.Http")
; Use your effectconnect public key here..
$oHttp.SetRequestHeader "KEY","PUBLIC_KEY"
$oHttp.SetRequestHeader "VERSION",$sApiVersion
$oHttp.SetRequestHeader "URI",$sUri
$oHttp.SetRequestHeader "RESPONSETYPE","XML"
$oHttp.SetRequestHeader "RESPONSELANGUAGE","en"
; Get the current date/time in timestamp format.
$oDt = ObjCreate("Chilkat.CkDateTime")
$oDt.SetFromCurrentSystemTime()
Local $sTimestamp = $oDt.GetAsTimestamp(True)
$oHttp.SetRequestHeader "TIME",$sTimestamp
ConsoleWrite("timestamp = " & $sTimestamp & @CRLF)
; Create the following XML request body:
; <?xml version="1.0" encoding="utf-8"?>
; <list>
; <filters>
; <fromDateFilter>
; <filterValue>2018-09-14T12:12:12+01:00</filterValue>
; </fromDateFilter>
; <toDateFilter>
; <filterValue>2019-04-13T23:59:59+01:00</filterValue>
; </toDateFilter>
; <hasStatusFilter>
; <filterValue>paid</filterValue>
; </hasStatusFilter>
; <hasTagFilter>
; <filterValue>
; <tagName>Test</tagName>
; <exclude>false</exclude>
; </filterValue>
; </hasTagFilter>
; </filters>
; </list>
; Use this online tool to generate the code from sample XML:
; Generate Code to Create XML
$oXml = ObjCreate("Chilkat.Xml")
$oXml.Tag = "list"
$oXml.UpdateChildContent "filters|fromDateFilter|filterValue","2018-09-14T12:12:12+01:00"
$oXml.UpdateChildContent "filters|toDateFilter|filterValue","2019-04-13T23:59:59+01:00"
$oXml.UpdateChildContent "filters|hasStatusFilter|filterValue","paid"
$oXml.UpdateChildContent "filters|hasTagFilter|filterValue|tagName","Test"
$oXml.UpdateChildContent "filters|hasTagFilter|filterValue|exclude","false"
$oXml.EmitCompact = True
$oSbXml = ObjCreate("Chilkat.StringBuilder")
$oXml.GetXmlSb($oSbXml)
; Build a string-to-sign and sign it using our effectconnect private key
$oSbStringToSign = ObjCreate("Chilkat.StringBuilder")
$oSbStringToSign.AppendInt($oSbXml.Length)
$oSbStringToSign.Append("POST")
$oSbStringToSign.Append($sUri)
$oSbStringToSign.Append($sApiVersion)
$oSbStringToSign.Append($sTimestamp)
$oCrypt = ObjCreate("Chilkat.Crypt2")
$oCrypt.MacAlgorithm = "hmac"
$oCrypt.HashAlgorithm = "sha512"
$oCrypt.EncodingMode = "base64"
; Use your effectconnect private key here:
$oCrypt.SetMacKeyString("PRIVATE_KEY")
$oHttp.SetRequestHeader "SIGNATURE",$oCrypt.MacStringENC($oSbStringToSign.GetAsString())
; Send the POST..
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpStr("POST",$sFullUri,$oXml.GetXml(),"utf-8","application/xml",$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("response status code = " & $oResp.StatusCode & @CRLF)
; Examine the response. The response status code can be 200 for both errors and success.
; The success or error is based on the XML returned in the response body.
$oXmlResp = ObjCreate("Chilkat.Xml")
$oXmlResp.LoadXml($oResp.BodyStr)
ConsoleWrite("response body:" & @CRLF)
ConsoleWrite($oXmlResp.GetXml() & @CRLF)
; Remove previously set headers (unless we want the same headers for the next request,
; in which case we may remove or update individual headers by calling SetRequestHeader.
$oHttp.ClearHeaders