Changes between Initial Version and Version 1 of API


Ignore:
Timestamp:
Nov 16, 2006, 9:29:08 PM (12 years ago)
Author:
omry
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • API

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