| ID | Creation date | June 20, 2009 | |
| Platform | S60 3rd and 5th Editions | Tested on devices | E71, XpressMusic 5800 |
| Category | Python | Subcategory | appuifw |
| Keywords (APIs, classes, methods, functions): appuifw, toolbar, canvas, graphics, wordpress, statistics |
Blogs using wordpress engine has a special page to display statistical information about your blog. It is possible to see blog views and post views, referees and searched terms, for instance. This information is available as well via HTTP, allowing third part access. It is only required an API key and an appropriated HTTP GET request. Moreover, Wordpress can send responses in CSV (comma separated values) or XML.
For direct access, you need to provide some parameters for GET request like API key, blog URI and blog ID (the complete list of parameters can be found here):
A typical request for blog views could be:
http://stats.wordpress.com/csv.php?api_key=my_key&blog_uri=http://my_blog.wordpress.com&blog_id=0
In this article will be proposed an API wrapper for Wordpress statistics, written in Python and based on urllib. This API will be used in a PyS60 application called WPStats, suitable for S60 3rd and 5th editions (only Python for S60 1.9.5 or newer).
Using the proposed API, called wpstatsapi.py, it is simple to retrieve your daily blog views with just few lines:
from wpstatsapi import *
api_key = "012345abcdef" # put your key here
blog_uri = "http://blog_name.wordpress.com" # put your blog URI here
wps = WPStats(api_key,blog_uri)
bv_daily = wps.get_blog_views()
An array with tuples in the format ('data',views) will be returned, like below:
[('2009-05-24', 91),
('2009-05-25', 149),
('2009-05-26', 162),
('2009-05-27', 339),
...,
('2009-05-28', 278)]
It is possible to convert from daily to weekly or monthly, just calling conv2monthly() or conv2weekly() functions.
bv_daily = wps.get_blog_views()
bv_weekly = conv2weekly(bv_daily)
bv_monthly = conv2monthly(bv_daily)
Besides blog views, the following methods are implemented (see source code for better explanation about parameters and response format):
All parameters can be reconfigured using reconfigure() and proxies are supported as well.
WPStats is available for touch and non touch S60 devices (Python 1.9.5) and has some nice features, like:
Zoom and proxy support are missing yet. For proxy, it is just a matter of creating the setup dialog.
You can see this application in action in the following video.
Source code is available in the Wordmobi repository: [1]. Or you can download the sis file.
No related wiki articles found