Changes between Initial Version and Version 1 of API_1.0


Ignore:
Timestamp:
Jul 11, 2007, 8:06:14 PM (10 years ago)
Author:
omry
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • API_1.0

    v1 v1  
     1== FireStats API ==
     2'''This is for historical reference, please use the latest version of the [wiki:API]'''
     3
     4As of version 1.0.0, FireStats provide several API calls that allow you to access statistics and other FireStats resources.[[BR]]
     5At the moment, the API is officially supported only under Wordpress. (if you would like support for other platform please submit an enhancment request).[[BR]]
     6However, if you feel like hacking, the APIs are defined in the file '''php/api.php'''.[[BR]]
     7
     8if the API file is included, 'FS_API' is defined. this allow you to test if its safe to call FireStats API functions like this:
     9
     10{{{
     11#!php
     12<?php
     13if (defined('FS_API'))
     14{
     15   // call API here.
     16}
     17?>
     18}}}
     19
     20The following APIs are supported:
     21{{{
     22#!php
     23<?php
     24/*
     25    Returns the number of pages displayed in the specified time period.
     26    days_ago is an optional parameter which specifies how many days ago to start counting.
     27    if days_ago is not specified, the count will begin when you installed FireStats.
     28*/
     29function fs_api_get_hit_count($days_ago = NULL);
     30
     31/*
     32    Returns the number of unique hits in the specified time period.
     33    days_ago is an optional parameter which specifies how many days ago to start counting.
     34    if days_ago is not specified, the count will begin when you installed FireStats.
     35*/
     36function fs_api_get_unique_hit_count($days_ago = NULL);
     37
     38/*
     39    Returns image tags of images representing the useragent
     40    3 Icons may be returned:
     41    * OS Icon
     42    * Browser Icon
     43    * PDA Icon (if the useagent is of a phone)
     44
     45    To access the user agent of the current user in PHP use $_SERVER['HTTP_USER_AGENT']
     46*/
     47function fs_api_get_browser_and_os_images($useragent);
     48
     49
     50/*
     51    Returns an image tag with the flag of the country this ip_address blonged to.
     52    if unknown, an empty string is returned.
     53*/
     54function fs_api_get_country_flag_image($ip_address);
     55
     56/*
     57    Returns a two characters country code of the country this ip address is belonged to.
     58    if unknown, false is returned.
     59*/
     60function fs_api_get_country_code($ip_address);
     61
     62?>
     63}}}
     64
     65
     66== Example ==
     67Here is an example usage of the FireStats API.
     68{{{
     69#!php
     70<?php
     71if (defined('FS_API'))
     72{
     73    echo "Hit count ever : ".fs_api_get_hit_count()."<BR/>";
     74    echo "Hit count in last day : ".fs_api_get_hit_count(1)."<BR/>";
     75    echo "Your browser and OS icons are :". fs_api_get_browser_and_os_images($_SERVER['HTTP_USER_AGENT'])."<BR/>";
     76    echo "Your country flag is : " .fs_api_get_country_flag_image($_SERVER['REMOTE_ADDR'])."<BR/>";
     77}
     78?>
     79}}}