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
(Unicode C++) Adobe Analytics Reporting API (1.4)Demonstrates a simple POST of JSON to the Adobe Analytics Reporting API (v1.4)
#include <CkJsonObjectW.h> #include <CkHttpW.h> #include <CkDateTimeW.h> #include <CkPrngW.h> #include <CkStringBuilderW.h> #include <CkCrypt2W.h> #include <CkHttpResponseW.h> void ChilkatSample(void) { // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. bool success; // In this example, replace "rsid" with your report suite id, and update the URL to use the correct endpoint const wchar_t *url = L"https://api.omniture.com/admin/1.4/rest/?method=Report.Queue"; CkJsonObjectW json; json.UpdateString(L"reportDescription.reportSuiteID",L"rsid"); json.UpdateString(L"reportDescription.dateGranularity",L"hour"); CkHttpW http; CkDateTimeW dt; dt.SetFromCurrentSystemTime(); const wchar_t *timecreated = dt.getAsTimestamp(false); CkPrngW prng; const wchar_t *nonce = prng.genRandom(12,L"hex"); const wchar_t *secret = L"SECRET"; CkStringBuilderW sb; sb.Append(nonce); sb.Append(timecreated); sb.Append(secret); CkCrypt2W crypt; crypt.put_HashAlgorithm(L"sha1"); crypt.put_EncodingMode(L"base64"); const wchar_t *digest = crypt.hashStringENC(sb.getAsString()); CkStringBuilderW sbNonce; sbNonce.Append(nonce); sbNonce.Encode(L"base64"); sb.Clear(); sb.Append(L"UsernameToken Username=\"USERNAME\", PasswordDigest=\""); sb.Append(digest); sb.Append(L"\", Nonce=\""); sb.Append(sbNonce.getAsString()); sb.Append(L"\", Created=\""); sb.Append(timecreated); sb.Append(L"\""); wprintf(L"%s\n",sb.getAsString()); http.SetRequestHeader(L"X-WSSE",sb.getAsString()); CkHttpResponseW *resp = http.PostJson2(url,L"text/json",json.emit()); if (http.get_LastMethodSuccess() != true) { wprintf(L"%s\n",http.lastErrorText()); return; } wprintf(L"Http Status code: %d\n",resp->get_StatusCode()); wprintf(L"JSON response:\n"); wprintf(L"%s\n",resp->bodyStr()); delete resp; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.