Here is a quick example of using Ruby to call WebTrends Web Services:
def query(account, username, password, query)
hostname = "ws.webtrends.com"
https = Net::HTTP.new(hostname, Net::HTTP.https_default_port)
https.use_ssl = true
https.ca_file = "/usr/share/curl/curl-ca-bundle.crt"
resp = https.start { |http|
request = Net::HTTP::Get.new("/beta/ReportService.svc/" + query)
request.basic_auth account + '\\' + username, password
res = http.request(request)
case res
when Net::HTTPSuccess, Net::HTTPRedirection
return res.body
else
res.error!
end
}
end
The method call would look something like this:
@foo = query("My Account", "My User Name", "My Password", "profile/?format=json")