PHP Classes
elePHPant
Icontem

File: utils/request.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Michele Andreoli  >  SmartGAPI  >  utils/request.php  >  Download  
File: utils/request.php
Role: Example script
Content type: text/plain
Description: script for the ajax request
Class: SmartGAPI
Display site statistics from Google Analytics
Author: By
Last change: Security bug fixed
Date: 4 years ago
Size: 1,361 bytes
 

Contents

Class file image Download
<?php
/**
 * @author Michele Andreoli <michi.andreoli@gmail.com>
 * @name request.php
 * @version 0.3 updated 07-04-2011
 * @license http://opensource.org/licenses/gpl-license-php GNU Public License
 * @package SmartGAPI
 */

    /***** BEGIN *****/
    /* This code retrieves informations from Google Analytics in background */

    /******************************************/
    /* E-MAIL */
   
$email = "<your email>";
   
/* PASSWORD */
   
$password = "<your password>";
   
/******************************************/

   
$dir = $_POST['dir'];
   
$id = $_POST['id'];
   
$starting_date = $_POST['starting_date'];
   
$ending_date = $_POST['ending_date'];
   
$timezone = $_POST['timezone'];

    include_once
$dir;
   
$ga = new gapi($email, $password);
   
$ga->requestReportData($id, array('browser','browserVersion'), array('pageviews','visits'), null, null, $starting_date, $ending_date);
   
/***** END *****/
?>
<table>
    <tr class="views">
        <td>Pageviews</td>
        <td><?php echo $ga->getPageviews() ?></td>
    </tr>
    <tr class="visits">
        <td>Visits</td>
        <td><?php echo $ga->getVisits() ?></td>
    </tr>
    <tr class="footer">
        <td><a href="http://www.google.com/analytics/">by Google Analytics</a></td>
        <td></td>
    </tr>
</table>