Yes, you can absolutely use Java to access the data. Many people already have in creating Java apps, web apps, Android Java apps, and Blackberry Java ME apps.
We created our Data Extraction API in such a way that it is _code free_! You don't need any code to get data using our REST requests. In fact, try it out and log in and create a REST url from our http://generator.webtrends.com and then paste the REST URL into your browser address bar and the data will simply return (after you authenticate of course).
But I can give you some helpful pointers for getting your Java app running with our data embedded in it.
The process is simple.
- All you need is a java library for making an https connection.
- Pass your webtrends account name along with your username in the authentication process with a backslash seperator.
- Create your REST request in generator.webtrends.com and choose a format you prefer.
- Add a parser library to your java code for the format you chose.
Step by step pointers:
1) For libraries, to make an Extraction request, all you need is any method of making an https request (there are lots of http helper libraries out there) with authentication. In order to make this as easy to embed in applications as possible, we use http authentication. Here is a link to apache commons libraries: http://commons.apache.org/
2) when you pass your username and password in the https request you need to follow this format:
Username should look like: webtrendsAccountName\userName (i.e. the username should have your webt account, backslash, username)
Password should look like: password (send your password as normal of course)
3) practice with a simple Webtrends REST request first. Create one in generator (http://generator.webtrends.com) from a basic report for "this month" and copy and paste the URL it generates for you into your test code.
4) once you send the https request Webtrends will respond with all the data. No extra code is needed of any kind. In fact, if you were to paste that REST request into your browser, the data would simply show in your browser window.
Do you want it in XML, JSON or HTML format?
Many developers find it easiest to recieve data in XML because there are so many XML parsers out there. See my link above to apache commons.
I suggest you use our XML format made friendly for developers and change your rest request to show format=xml2
That "xml2" is not a typo. We have two xml formats to use and xml2 is the easiest to automate parsing for.
5) get yourself a java parser for the format you chose in step 4. Apache commons has one for both XML and JSON. If you want to pursue JSON further (json is more compact, faster and efficient but not as easy to develop for) go to http://json.org/index.html and scroll down and you'll find a dozen or more json parsers for every platform. If you are using Java to develop for Android, I recommend "gson".
Thanks for the reply. However, there's something more, I would like to know in this regard. As suggested by you, the webtrends account name, username and password should be sent as parameters in the second step of the development process. Can you please clarify, how can I get these credentials? Do I need to do any sort of registration for obtaining these credentials?
Thanks & Regards,
You just need to be a Webtrends customer. The credentials just tells us what data you are trying to access (and whether or not you have the rights to access it).
There are several options.
First of all, if you are in our new Insight user interface, even in on-premises there is a "Share" button. When you click on that you can see the REST urls for the reports and it shows your own domain address for the web services. It's using the same method as Generator is for your on-premises.
But really the thing that is super useful about Generator for me is that it gives you a first intro to how REST works and then it is a good tool for getting your profile and report IDs for various data. Using the Share feature will show the IDs the same way.
Your next option is that you may not know this but you can actually just browse the REST data in your web browser, no Generator or html page needed. Just use format=xml or format=html in your parameters and you can view the data returned right in your browse and change the parameters in your address bar. This is the advanced users way of exploring the REST.
The one option I don't have for you right now though is there isn't an "offline" way of doing the Generator type functions.
Thank you for your prompt reply. However, I do not see the share button. Therefore, I think either I do not have the correct premission or it was not installed on our server. Our version is 22.214.171.1240. Is it supposed to have Insight user interface? If so, is there a special permission on user account for that user interface?
The good news is that 9.2 has the Insight interface... but the person that installed and configured your environment needed to assign it to a particular address. Typically people create a subdomain for insight like insight.[yourdomain].com or something like that.
To be honest, Insight is the interface all users should be accessing to see Webtrends. The console interface most are used to from the past is really meant for an admins to configure profiles, create new metrics, etc. But in terms of understanding your site and viewing Analytics, you really should be using Insight.
Here is a screenshot of what you should be seeing:
Hi Paul, i used the generator to got an URL for a java Client extractor.
When i try to invoke this URL i have a "connection refused" exception (maybe i'm doing something wrong in authentication), could you help posting an example code snippet?
I'm using the Apache HttpComponents.
Thank you very much