Unicode C++
Unicode C++
Adobe Analytics Reporting API (1.4)
See more HTTP Misc Examples
Demonstrates a simple POST of JSON to the Adobe Analytics Reporting API (v1.4)Chilkat Unicode C++ Downloads
#include <CkJsonObjectW.h>
#include <CkHttpW.h>
#include <CkDateTimeW.h>
#include <CkPrngW.h>
#include <CkStringBuilderW.h>
#include <CkCrypt2W.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
bool success = false;
// 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
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;
success = http.HttpJson(L"POST",url,json,L"text/json",resp);
if (success == false) {
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());
}