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
(PowerBuilder) Adobe Analytics Reporting API (1.4)Demonstrates a simple POST of JSON to the Adobe Analytics Reporting API (v1.4)
integer li_rc integer li_Success string ls_Url oleobject loo_Json oleobject loo_Http oleobject loo_Dt string ls_Timecreated oleobject loo_Prng string ls_Nonce string ls_Secret oleobject loo_Sb oleobject loo_Crypt string ls_Digest oleobject loo_SbNonce oleobject loo_Resp // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // In this example, replace "rsid" with your report suite id, and update the URL to use the correct endpoint ls_Url = "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue" loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") if li_rc < 0 then destroy loo_Json MessageBox("Error","Connecting to COM object failed") return end if loo_Json.UpdateString("reportDescription.reportSuiteID","rsid") loo_Json.UpdateString("reportDescription.dateGranularity","hour") loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") loo_Dt = create oleobject // Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0 li_rc = loo_Dt.ConnectToNewObject("Chilkat.CkDateTime") loo_Dt.SetFromCurrentSystemTime() ls_Timecreated = loo_Dt.GetAsTimestamp(0) loo_Prng = create oleobject // Use "Chilkat_9_5_0.Prng" for versions of Chilkat < 10.0.0 li_rc = loo_Prng.ConnectToNewObject("Chilkat.Prng") ls_Nonce = loo_Prng.GenRandom(12,"hex") ls_Secret = "SECRET" loo_Sb = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_Sb.ConnectToNewObject("Chilkat.StringBuilder") loo_Sb.Append(ls_Nonce) loo_Sb.Append(ls_Timecreated) loo_Sb.Append(ls_Secret) loo_Crypt = create oleobject // Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2") loo_Crypt.HashAlgorithm = "sha1" loo_Crypt.EncodingMode = "base64" ls_Digest = loo_Crypt.HashStringENC(loo_Sb.GetAsString()) loo_SbNonce = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbNonce.ConnectToNewObject("Chilkat.StringBuilder") loo_SbNonce.Append(ls_Nonce) loo_SbNonce.Encode("base64") loo_Sb.Clear() loo_Sb.Append("UsernameToken Username=~"USERNAME~", PasswordDigest=~"") loo_Sb.Append(ls_Digest) loo_Sb.Append("~", Nonce=~"") loo_Sb.Append(loo_SbNonce.GetAsString()) loo_Sb.Append("~", Created=~"") loo_Sb.Append(ls_Timecreated) loo_Sb.Append("~"") Write-Debug loo_Sb.GetAsString() loo_Http.SetRequestHeader("X-WSSE",loo_Sb.GetAsString()) loo_Resp = loo_Http.PostJson2(ls_Url,"text/json",loo_Json.Emit()) if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Json destroy loo_Http destroy loo_Dt destroy loo_Prng destroy loo_Sb destroy loo_Crypt destroy loo_SbNonce return end if Write-Debug "Http Status code: " + string(loo_Resp.StatusCode) Write-Debug "JSON response:" Write-Debug loo_Resp.BodyStr destroy loo_Resp destroy loo_Json destroy loo_Http destroy loo_Dt destroy loo_Prng destroy loo_Sb destroy loo_Crypt destroy loo_SbNonce |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.