PHP
PHP
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 PHP Downloads
<?php
use Chilkat2\Crypt2;
use Chilkat2\DateTime;
use Chilkat2\Http;
use Chilkat2\HttpResponse;
use Chilkat2\JsonObject;
use Chilkat2\Prng;
use Chilkat2\StringBuilder;
// 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
$url = 'https://api.omniture.com/admin/1.4/rest/?method=Report.Queue';
$json = new JsonObject();
$json->UpdateString('reportDescription.reportSuiteID', 'rsid');
$json->UpdateString('reportDescription.dateGranularity', 'hour');
$http = new Http();
$dt = new DateTime();
$dt->SetFromCurrentSystemTime();
$timecreated = $dt->GetAsTimestamp(false);
$prng = new Prng();
$nonce = $prng->GenRandom(12, 'hex');
$secret = 'SECRET';
$sb = new StringBuilder();
$sb->Append($nonce);
$sb->Append($timecreated);
$sb->Append($secret);
$crypt = new Crypt2();
$crypt->HashAlgorithm = 'sha1';
$crypt->EncodingMode = 'base64';
$digest = $crypt->HashStringENC($sb->GetAsString());
$sbNonce = new StringBuilder();
$sbNonce->Append($nonce);
$sbNonce->Encode('base64', 'utf-8');
$sb->Clear();
$sb->Append('UsernameToken Username="USERNAME", PasswordDigest="');
$sb->Append($digest);
$sb->Append('", Nonce="');
$sb->Append($sbNonce->GetAsString());
$sb->Append('", Created="');
$sb->Append($timecreated);
$sb->Append('"');
echo $sb->GetAsString(), "\n";
$http->SetRequestHeader('X-WSSE', $sb->GetAsString());
$resp = new HttpResponse();
try {
$http->HttpJson('POST', $url, $json, 'text/json', $resp);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo 'Http Status code: ', $resp->StatusCode, "\n";
echo "JSON response:\n";
echo $resp->BodyStr, "\n";