Mainos / Advertisement:

Google calendar api

From Taisto
Jump to navigation Jump to search


require_once '/var/www/src/Google_Client.php';
require_once '/var/www/src/contrib/Google_AnalyticsService.php';
$scriptUri = "$
$client = new Google_Client();
$client->setAccessType('online'); // default: offline
$client->setDeveloperKey('AIzaSyD-qvvRkkKn8D6367oS4xgTyM9dnLhqfmY'); // API key
// $service implements the client interface, has to be set before auth call
$service = new Google_AnalyticsService($client);
if (isset($_GET['logout'])) { // logout: destroy token
       die('Logged out.');
if (isset($_GET['code'])) { // we received the positive auth callback, get the token and store it in session
   $_SESSION['token'] = $client->getAccessToken();
if (isset($_SESSION['token'])) { // extract token from session and configure client
   $token = $_SESSION['token'];
if (!$client->getAccessToken()) { // auth call to google
   $authUrl = $client->createAuthUrl();
   header("Location: ".$authUrl);
echo 'Hello, world.';
Mainos / Advertisement: