Skip to content

Instantly share code, notes, and snippets.

@kovagoz
Created August 9, 2016 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovagoz/642942fa55d039f3c49d0a94cc7e6655 to your computer and use it in GitHub Desktop.
Save kovagoz/642942fa55d039f3c49d0a94cc7e6655 to your computer and use it in GitHub Desktop.
Count Google Calendars
<?php
require __DIR__ . '/vendor/autoload.php';
$credentials_path = __DIR__ . '/credentials.json';
putenv("GOOGLE_APPLICATION_CREDENTIALS=$credentials_path");
$client = new Google_Client;
$client->useApplicationDefaultCredentials();
$client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
$service = new Google_Service_Calendar($client);
$cals = $service->calendarList->listCalendarList();
echo count($cals), PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment