You Are Here:

Community: Wiki

This page was last modified on 22 June 2009, at 02:48.

API and demo application for accessing Wordpress statistics

From Forum Nokia Wiki


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

Introduction

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).

Wordpress statistics API

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):

  • get_post_views(): Get the number of views for a given post id or number of views for all posts.
  • get_referrers(): Get the list of referrers.
  • get_search_terms(): Get the list o search terms.
  • get_clicks(): Get link clicks.

All parameters can be reconfigured using reconfigure() and proxies are supported as well.

Wordpress statistics application

WPStats is available for touch and non touch S60 devices (Python 1.9.5) and has some nice features, like:

  • Transparent toolbar at left for all functions. I decided not to use menus and save screen space. The same reason for avoiding labels (better to use popups).
  • Three views: daily, weekly and monthly blog views. In weekly mode, the week number is showed after the year.
  • Data persistence and configurable number of days to consider in the statistic.

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.

WPStats Screenshot


Source code and sis

Source code is available in the Wordmobi repository: [1]. Or you can download the sis file.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fCreatingE5ftrendE5fgraphicsE5fonE5fcanvasX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxpythonX qfnZuserE5ftagQSxs60X qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ