// Magic. Returns objects from the Analytics Service // instead of associative arrays. $client->setUseObjects(true); // Build a new storage object to handle and store tokens in sessions. // Create a new storage object to persist the tokens across sessions. $storage = new apiSessionStorage(); $authHelper = new AuthHelper($client, $storage, THIS_PAGE); // Main controller logic. if ($_GET['action'] == 'revoke') { $authHelper->revokeToken(); } else { if ($_GET['action'] == 'auth' || $_GET['code']) { $authHelper->authenticate(); } else { $authHelper->setTokenFromStorage(); if ($authHelper->isAuthorized()) { $analytics = new Google_AnalyticsService($client); if ($_GET['demo'] == 'hello') { // Hello Analytics API Demo. require_once 'helloAnalyticsApi.php'; $demo = new HelloAnalyticsApi($analytics); $htmlOutput = $demo->getHtmlOutput(); $demoError = $demo->getError(); } else { if ($_GET['demo'] == 'mgmt') { // Management API Reference Demo. require_once 'managementApiReference.php'; $demo = new ManagementApiReference($analytics); $htmlOutput = $demo->getHtmlOutput(); $demoError = $demo->getError(); } else {