Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) effectconnect Product UpdateUse this call to update a product (f.e. stock or price) in EffectConnect.
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. Local $bSuccess Local $sUri = "/products" Local $sApiVersion = "2.0" $oHttp = ObjCreate("Chilkat.Http") $oReq = ObjCreate("Chilkat.HttpRequest") ; Use your effectconnect public key here... $oReq.AddHeader "KEY","PUBLIC_KEY" $oReq.AddHeader "VERSION",$sApiVersion $oReq.AddHeader "URI",$sUri $oReq.AddHeader "RESPONSETYPE","XML" $oReq.AddHeader "RESPONSELANGUAGE","en" ; Get the current date/time in timestamp format. $oDt = ObjCreate("Chilkat.CkDateTime") $oDt.SetFromCurrentSystemTime() Local $sTimestamp = $oDt.GetAsTimestamp(True) $oReq.AddHeader "TIME",$sTimestamp ConsoleWrite("timestamp = " & $sTimestamp & @CRLF) $oSbXml = ObjCreate("Chilkat.StringBuilder") $bSuccess = $oSbXml.LoadFile("qa_data/xml/effectconnect/effconUpdate.xml","utf-8") ConsoleWrite("length = " & $oSbXml.Length & @CRLF) $oReq.HttpVerb = "PUT" $oReq.Path = $sUri $oReq.ContentType = "multipart/form-data" $bSuccess = $oReq.AddStringForUpload("payload","effconUpdate.xml",$oSbXml.GetAsString(),"utf-8") If ($bSuccess = False) Then ConsoleWrite($oReq.LastErrorText & @CRLF) Exit EndIf ; Build a string-to-sign and sign it using our effectconnect private key $oSbStringToSign = ObjCreate("Chilkat.StringBuilder") $oSbStringToSign.AppendInt($oSbXml.Length) $oSbStringToSign.Append("PUT") $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") $oReq.AddHeader "SIGNATURE",$oCrypt.MacStringENC($oSbStringToSign.GetAsString()) Local $oResp = $oHttp.SynchronousRequest("submit.effectconnect.com",443,True,$oReq) If ($oHttp.LastMethodSuccess = 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) ; A sample response: ; <?xml version="1.0" encoding="utf-8"?> ; <ApiResponseContainer> ; <Request> ; <RequestType>Products</RequestType> ; <RequestAction>Update</RequestAction> ; <RequestVersion>2.0</RequestVersion> ; <RequestIdentifier/> ; <ProcessedAt>2019-04-18T15:37:32+02:00</ProcessedAt> ; </Request> ; <Response> ; <Result>Success</Result> ; <ProductsUpdateResponseContainer> ; <ProcessID><![CDATA[f81ngzD2S7gooFk3]]></ProcessID> ; </ProductsUpdateResponseContainer> ; </Response> ; </ApiResponseContainer> ; Local $sTagPath Local $sRequestType Local $sRequestAction Local $sRequestVersion Local $sProcessedAt Local $sResult Local $sProcessID $sRequestType = $oXmlResp.GetChildContent("Request|RequestType") $sRequestAction = $oXmlResp.GetChildContent("Request|RequestAction") $sRequestVersion = $oXmlResp.GetChildContent("Request|RequestVersion") $sProcessedAt = $oXmlResp.GetChildContent("Request|ProcessedAt") $sResult = $oXmlResp.GetChildContent("Response|Result") $sProcessID = $oXmlResp.GetChildContent("Response|ProductsUpdateResponseContainer|ProcessID") |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.