Saturday, March 9, 2013

Creating a AWStats API

For my AWStats Viewer app for WP8 I need to be able to get the web statistic from the website some way.
I do not want the app to parse the AWStats webpage since since it does not show all the information I want. I need the data from the AWStats data files. Not all of it but I need it unmodified.

But the data files can be very large and having the app get fetch the data file and parse it is not a good idea.
Because download several MB of data everything the app need to update is not god. It would be slow and require a lot of memory also background task have a memory limit.

What I need is a Web API. I need to be able to send a query the website and have it return the result as JSON.

The Webserver is running PHP so from PHP I need to read and parse the AWStats Data file and extract the information that is wanted and place create some JSON data from it and return it.

I search the net for some PHP class that would parse the AWStats data and I found awparser that is made by Javier Infante.

The AWParser class is not perfect, It does not extract all information I need and it stores the data in a way that is not optimal for my needs, But I will be able to modify it easily so I think I can make it work for me.

After that I will have all the AWStats data in PHP arrays and php can convert arrays to JSON with json_encode(..) so it would be easy to return the data as JSON.

So when I created this API I will publish the API on my website so anyone can install it on their own site if they want to develop own app for it or use my Awstats Viewer app in the future.

1 comment:

  1. The splashes of color make each game look enticing. As you’d count on, there are particular person classes for all game types and you'll quickly see which studio has developed every title. We notably loved the playability on cellular gadgets. You can also quickly 카지노사이트 see the important thing} information about a given game, which can be invaluable whenever you wish to figure out which game you need to} play next. Each game sort is perfectly broken down into varied subcategories.