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
(PureBasic) Adobe Analytics Reporting API (1.4)Demonstrates a simple POST of JSON to the Adobe Analytics Reporting API (v1.4)
IncludeFile "CkJsonObject.pb" IncludeFile "CkDateTime.pb" IncludeFile "CkPrng.pb" IncludeFile "CkHttp.pb" IncludeFile "CkCrypt2.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkHttpResponse.pb" Procedure ChilkatExample() ; This requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. success.i ; In this example, replace "rsid" with your report suite id, and update the URL to use the correct endpoint url.s = "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue" json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(json,"reportDescription.reportSuiteID","rsid") CkJsonObject::ckUpdateString(json,"reportDescription.dateGranularity","hour") http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf dt.i = CkDateTime::ckCreate() If dt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkDateTime::ckSetFromCurrentSystemTime(dt) timecreated.s = CkDateTime::ckGetAsTimestamp(dt,0) prng.i = CkPrng::ckCreate() If prng.i = 0 Debug "Failed to create object." ProcedureReturn EndIf nonce.s = CkPrng::ckGenRandom(prng,12,"hex") secret.s = "SECRET" sb.i = CkStringBuilder::ckCreate() If sb.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sb,nonce) CkStringBuilder::ckAppend(sb,timecreated) CkStringBuilder::ckAppend(sb,secret) crypt.i = CkCrypt2::ckCreate() If crypt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkCrypt2::setCkHashAlgorithm(crypt, "sha1") CkCrypt2::setCkEncodingMode(crypt, "base64") digest.s = CkCrypt2::ckHashStringENC(crypt,CkStringBuilder::ckGetAsString(sb)) sbNonce.i = CkStringBuilder::ckCreate() If sbNonce.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbNonce,nonce) CkStringBuilder::ckEncode(sbNonce,"base64") CkStringBuilder::ckClear(sb) CkStringBuilder::ckAppend(sb,"UsernameToken Username=" + Chr(34) + "USERNAME" + Chr(34) + ", PasswordDigest=" + Chr(34)) CkStringBuilder::ckAppend(sb,digest) CkStringBuilder::ckAppend(sb,Chr(34) + ", Nonce=" + Chr(34)) CkStringBuilder::ckAppend(sb,CkStringBuilder::ckGetAsString(sbNonce)) CkStringBuilder::ckAppend(sb,Chr(34) + ", Created=" + Chr(34)) CkStringBuilder::ckAppend(sb,timecreated) CkStringBuilder::ckAppend(sb,Chr(34)) Debug CkStringBuilder::ckGetAsString(sb) CkHttp::ckSetRequestHeader(http,"X-WSSE",CkStringBuilder::ckGetAsString(sb)) resp.i = CkHttp::ckPostJson2(http,url,"text/json",CkJsonObject::ckEmit(json)) If CkHttp::ckLastMethodSuccess(http) <> 1 Debug CkHttp::ckLastErrorText(http) CkJsonObject::ckDispose(json) CkHttp::ckDispose(http) CkDateTime::ckDispose(dt) CkPrng::ckDispose(prng) CkStringBuilder::ckDispose(sb) CkCrypt2::ckDispose(crypt) CkStringBuilder::ckDispose(sbNonce) ProcedureReturn EndIf Debug "Http Status code: " + Str(CkHttpResponse::ckStatusCode(resp)) Debug "JSON response:" Debug CkHttpResponse::ckBodyStr(resp) CkHttpResponse::ckDispose(resp) CkJsonObject::ckDispose(json) CkHttp::ckDispose(http) CkDateTime::ckDispose(dt) CkPrng::ckDispose(prng) CkStringBuilder::ckDispose(sb) CkCrypt2::ckDispose(crypt) CkStringBuilder::ckDispose(sbNonce) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.