Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL lcUrl
LOCAL loJson
LOCAL loHttp
LOCAL loDt
LOCAL lcTimecreated
LOCAL loPrng
LOCAL lcNonce
LOCAL lcSecret
LOCAL loSb
LOCAL loCrypt
LOCAL lcDigest
LOCAL loSbNonce
LOCAL loResp
lnSuccess = 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
lcUrl = "https://api.omniture.com/admin/1.4/rest/?method=Report.Queue"
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("reportDescription.reportSuiteID","rsid")
loJson.UpdateString("reportDescription.dateGranularity","hour")
loHttp = CreateObject('Chilkat.Http')
loDt = CreateObject('Chilkat.CkDateTime')
loDt.SetFromCurrentSystemTime()
lcTimecreated = loDt.GetAsTimestamp(0)
loPrng = CreateObject('Chilkat.Prng')
lcNonce = loPrng.GenRandom(12,"hex")
lcSecret = "SECRET"
loSb = CreateObject('Chilkat.StringBuilder')
loSb.Append(lcNonce)
loSb.Append(lcTimecreated)
loSb.Append(lcSecret)
loCrypt = CreateObject('Chilkat.Crypt2')
loCrypt.HashAlgorithm = "sha1"
loCrypt.EncodingMode = "base64"
lcDigest = loCrypt.HashStringENC(loSb.GetAsString())
loSbNonce = CreateObject('Chilkat.StringBuilder')
loSbNonce.Append(lcNonce)
loSbNonce.Encode("base64")
loSb.Clear()
loSb.Append('UsernameToken Username="USERNAME", PasswordDigest="')
loSb.Append(lcDigest)
loSb.Append('", Nonce="')
loSb.Append(loSbNonce.GetAsString())
loSb.Append('", Created="')
loSb.Append(lcTimecreated)
loSb.Append('"')
? loSb.GetAsString()
loHttp.SetRequestHeader("X-WSSE",loSb.GetAsString())
loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpJson("POST",lcUrl,loJson,"text/json",loResp)
IF (lnSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loJson
RELEASE loHttp
RELEASE loDt
RELEASE loPrng
RELEASE loSb
RELEASE loCrypt
RELEASE loSbNonce
RELEASE loResp
CANCEL
ENDIF
? "Http Status code: " + STR(loResp.StatusCode)
? "JSON response:"
? loResp.BodyStr
RELEASE loJson
RELEASE loHttp
RELEASE loDt
RELEASE loPrng
RELEASE loSb
RELEASE loCrypt
RELEASE loSbNonce
RELEASE loResp