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: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5fgetE5fsystemE5finfoE5fonE5fsmartphoneX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxHowE20toE20getE20systemE20infoE20onE20smartphoneE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtopicQUqfnTopicZpythonQRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtopicQUqfnTopicZseriesE5f60QRqdcZtypeQUqrdfsZE52esourceQRqmarsZrelevanceQNx100X qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZupdatedQDx2008E2d10E2d06X qfnZuserE5ftagQSxpythonX qfnZuserE5ftagQSxs60X qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ