-
-
Save commuterjoy/5670640 to your computer and use it in GitHub Desktop.
Generate a report via the SiteCatalyst / Omniture API via Ruby & CURL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"reportDescription":{ | |
"reportSuiteID":"<report-suite-id>", | |
"date":"2013-05-11", | |
"dateFrom":"", | |
"dateTo":"", | |
"dateGranularity":"hour", | |
"metrics":[ | |
{ | |
"id":"event37" | |
} | |
], | |
"sortBy":"", | |
"elements":[ | |
{ | |
"id":"evar37", | |
"search":{ | |
"type":"AND", | |
"keywords":[ | |
"social-fb", | |
"social-twitter", | |
"social-gplus" | |
] | |
} | |
} | |
], | |
"locale":"", | |
"segment_id":"" | |
}, | |
"validate":true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'time' | |
require 'digest/md5' | |
require 'digest/sha1' | |
require 'base64' | |
url = 'https://api.omniture.com/admin/1.3/rest/?method=Report.QueueTrended' | |
username = '<username>' | |
password = '<password>' | |
nonce = Array.new(10){ rand(0x100000000) }.pack('I*') | |
nonce_base64 = [nonce].pack("m").chomp | |
created = Time.now.utc.iso8601 | |
pd = [Digest::SHA1.digest(nonce + created + password)].pack("m").chomp | |
auth = 'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"' % [username, pd, nonce_base64, created] | |
cmd = "curl -sH 'Content-Type: application/json' -H 'X-WSSE: %s' -d @body %s" % [auth, url] | |
puts cmd | |
puts `#{cmd}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment