AutoIt
AutoIt
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 AutoIt Downloads
Local $bSuccess = 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
Local $sUrl = "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue"
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("reportDescription.reportSuiteID","rsid")
$oJson.UpdateString("reportDescription.dateGranularity","hour")
$oHttp = ObjCreate("Chilkat.Http")
$oDt = ObjCreate("Chilkat.CkDateTime")
$oDt.SetFromCurrentSystemTime()
Local $sTimecreated = $oDt.GetAsTimestamp(False)
$oPrng = ObjCreate("Chilkat.Prng")
Local $sNonce = $oPrng.GenRandom(12,"hex")
Local $secret = "SECRET"
$oSb = ObjCreate("Chilkat.StringBuilder")
$oSb.Append($sNonce)
$oSb.Append($sTimecreated)
$oSb.Append($secret)
$oCrypt = ObjCreate("Chilkat.Crypt2")
$oCrypt.HashAlgorithm = "sha1"
$oCrypt.EncodingMode = "base64"
Local $sDigest = $oCrypt.HashStringENC($oSb.GetAsString())
$oSbNonce = ObjCreate("Chilkat.StringBuilder")
$oSbNonce.Append($sNonce)
$oSbNonce.Encode("base64")
$oSb.Clear
$oSb.Append("UsernameToken Username=""USERNAME"", PasswordDigest=""")
$oSb.Append($sDigest)
$oSb.Append(""", Nonce=""")
$oSb.Append($oSbNonce.GetAsString())
$oSb.Append(""", Created=""")
$oSb.Append($sTimecreated)
$oSb.Append("""")
ConsoleWrite($oSb.GetAsString() & @CRLF)
$oHttp.SetRequestHeader "X-WSSE",$oSb.GetAsString()
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST",$sUrl,$oJson,"text/json",$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Http Status code: " & $oResp.StatusCode & @CRLF)
ConsoleWrite("JSON response:" & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)