#!/usr/bin/php getReport($siteProfile, $start, $stop, 'visitspageviewscomparehr', $start2, $stop2); $last24hrs = process24hrs(processVisitsPageviews($visitspageviewscomparehr,true)); $data[] = processJSPrint($last24hrs, "hour"); // last 7 days $last7days = mktime(0, 0, 0, date("m"), date("d")-6, date("Y")); $start = date('Ymd', $last7days); $stop = date('Ymd', time()); $visitspageviews = $ga->getReport($siteProfile, $start, $stop, 'visitspageviews'); $data[] = processJSPrint(processVisitsPageviews($visitspageviews), "day"); // last 12 months $last12months = mktime(0, 0, 0, date("m")+1, date("d"), date("Y")-1); $start = date('Ymd', $last12months); $stop = date('Ymd', time()); $visitspageviewsmth = $ga->getReport($siteProfile, $start, $stop, 'visitspageviewsmth'); $data[] = processJSPrint(processVisitsPageviews($visitspageviewsmth), "year"); echo implode("",$data); } function getSites ( $ga ) { $accounts = $ga->getAccounts(); // get all the profiles for all the accounts foreach ( $accounts as $account ) { $profilelist[] = $ga->getSiteProfiles($account["id"]); } // print the array with all the profiles in it. Have to do this all at once otherwise // it causes havok in the widgets event handling. $i = 0; foreach ( $profilelist as $profiles ) { foreach($profiles as $profile){ print("siteList[{$i}] = Array(\"{$profile["name"]}\",{$profile["id"]});"); $i++; } } } $username = $argv[1]; $password = $argv[2]; $option = $argv[3]; $siteid = $argv[4]; require_once(dirname(__FILE__).'/tantan/lib.googleanalytics.php'); $ga = new tantan_GoogleAnalytics(); if (!$ga->login($username,$password)) { $error = "There was a problem logging into your Google Analytics account:
".$ga->getError(); echo "loginError = true; errorText = \"$error\";"; } else { // login ok $session = $ga->getSession(); } switch ( $option ) { case 'sites': getSites($ga); break; case 'stats': getStats($siteid, $ga); break; } ?>