Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

effectconnect Read Orderlist

See more effectconnect Examples

Get a set of orders filtered by the parameters in the XML payload.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL cFullUri
LOCAL cUri
LOCAL cApiVersion
LOCAL oHttp
LOCAL oDt
LOCAL cTimestamp
LOCAL oXml
LOCAL oSbXml
LOCAL oSbStringToSign
LOCAL oCrypt
LOCAL oResp
LOCAL oXmlResp

nSuccess := 0

//  This example assumes the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

cFullUri := "https://submit.effectconnect.com/orderlist"
cUri := "/orderlist"
cApiVersion := "2.0"

oHttp := CreateObject("Chilkat.Http")

//  Use your effectconnect public key here..
oHttp:SetRequestHeader("KEY", "PUBLIC_KEY")
oHttp:SetRequestHeader("VERSION", cApiVersion)
oHttp:SetRequestHeader("URI", cUri)
oHttp:SetRequestHeader("RESPONSETYPE", "XML")
oHttp:SetRequestHeader("RESPONSELANGUAGE", "en")

//  Get the current date/time in timestamp format.
oDt := CreateObject("Chilkat.CkDateTime")
oDt:SetFromCurrentSystemTime()
cTimestamp := oDt:GetAsTimestamp(1)

oHttp:SetRequestHeader("TIME", cTimestamp)
? "timestamp = " + cTimestamp

//  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 := CreateObject("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 := 1

oSbXml := CreateObject("Chilkat.StringBuilder")
oXml:GetXmlSb(oSbXml)

//  Build a string-to-sign and sign it using our effectconnect private key
oSbStringToSign := CreateObject("Chilkat.StringBuilder")
oSbStringToSign:AppendInt(oSbXml:Length)
oSbStringToSign:Append("POST")
oSbStringToSign:Append(cUri)
oSbStringToSign:Append(cApiVersion)
oSbStringToSign:Append(cTimestamp)

oCrypt := CreateObject("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 := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpStr("POST", cFullUri, oXml:GetXml(), "utf-8", "application/xml", oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oDt:destroy()
    oXml:destroy()
    oSbXml:destroy()
    oSbStringToSign:destroy()
    oCrypt:destroy()
    oResp:destroy()
    RETURN
ENDIF

? "response status code = " + Str(oResp:StatusCode)

//  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 := CreateObject("Chilkat.Xml")
oXmlResp:LoadXml(oResp:BodyStr)

? "response body:"
? oXmlResp:GetXml()

//  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()

oHttp:destroy()
oDt:destroy()
oXml:destroy()
oSbXml:destroy()
oSbStringToSign:destroy()
oCrypt:destroy()
oResp:destroy()
oXmlResp:destroy()