Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL cUrl
LOCAL oJson
LOCAL oHttp
LOCAL oDt
LOCAL cTimecreated
LOCAL oPrng
LOCAL cNonce
LOCAL cSecret
LOCAL oSb
LOCAL oCrypt
LOCAL cDigest
LOCAL oSbNonce
LOCAL oResp

nSuccess := 0

//  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
cUrl := "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue"

oJson := CreateObject("Chilkat.JsonObject")
oJson:UpdateString("reportDescription.reportSuiteID", "rsid")
oJson:UpdateString("reportDescription.dateGranularity", "hour")

oHttp := CreateObject("Chilkat.Http")

oDt := CreateObject("Chilkat.CkDateTime")
oDt:SetFromCurrentSystemTime()
cTimecreated := oDt:GetAsTimestamp(0)

oPrng := CreateObject("Chilkat.Prng")
cNonce := oPrng:GenRandom(12, "hex")

cSecret := "SECRET"

oSb := CreateObject("Chilkat.StringBuilder")
oSb:Append(cNonce)
oSb:Append(cTimecreated)
oSb:Append(cSecret)

oCrypt := CreateObject("Chilkat.Crypt2")
oCrypt:HashAlgorithm := "sha1"
oCrypt:EncodingMode := "base64"
cDigest := oCrypt:HashStringENC(oSb:GetAsString())

oSbNonce := CreateObject("Chilkat.StringBuilder")
oSbNonce:Append(cNonce)
oSbNonce:Encode("base64")

oSb:Clear()
oSb:Append('UsernameToken Username="USERNAME", PasswordDigest="')
oSb:Append(cDigest)
oSb:Append('", Nonce="')
oSb:Append(oSbNonce:GetAsString())
oSb:Append('", Created="')
oSb:Append(cTimecreated)
oSb:Append('"')

? oSb:GetAsString()

oHttp:SetRequestHeader("X-WSSE", oSb:GetAsString())

oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpJson("POST", cUrl, oJson, "text/json", oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oJson:destroy()
    oHttp:destroy()
    oDt:destroy()
    oPrng:destroy()
    oSb:destroy()
    oCrypt:destroy()
    oSbNonce:destroy()
    oResp:destroy()
    RETURN
ENDIF

? "Http Status code: " + Str(oResp:StatusCode)
? "JSON response:"
? oResp:BodyStr

oJson:destroy()
oHttp:destroy()
oDt:destroy()
oPrng:destroy()
oSb:destroy()
oCrypt:destroy()
oSbNonce:destroy()
oResp:destroy()