/home/desid573/cf.desidrivers.com.au/site/google/api/src/Google
NameSizeModeActions
AccessToken/-0755rm
AuthHandler/-0755rm
Http/-0755rm
Service/-0755rm
Task/-0755rm
Utils/-0755rm
autoload.php7210644editdlrm
calendarAdd.php29170644editdlrm
Client.php317860644editdlrm
client_secret.json4290644editdlrm
Collection.php23730644editdlrm
error_log17110644editdlrm
Exception.php6470644editdlrm
Model.php87950644editdlrm
Service.php12890644editdlrm
Edit: /home/desid573/cf.desidrivers.com.au/site/google/api/src/Google/calendarAdd.php (2917B)
setApplicationName('Google Calendar API PHP Quickstart'); $client->setAuthConfig("client_secret.json"); $client->setAccessType('offline'); $client->setScopes(Google_Service_Calendar); // Load previously authorized credentials from a file. $credentialsPath = expandHomeDirectory('credentials.json'); if (file_exists($credentialsPath)) { $accessToken = json_decode(file_get_contents($credentialsPath), true); } else { // Request authorization from the user. //$authUrl = $client->createAuthUrl(); //printf("Open the following link in your browser:\n%s\n", $authUrl); //print 'Enter verification code: '; $authCode = "4/AAC76TQo2gYinBP75KW-p_Dl02z6YvFp-jQFxzpX0S-Y4bDZO96L_xU"; // Exchange authorization code for an access token. $accessToken = $client->fetchAccessTokenWithAuthCode($authCode); // Store the credentials to disk. if (!file_exists(dirname($credentialsPath))) { mkdir(dirname($credentialsPath), 0700, true); } file_put_contents($credentialsPath, json_encode($accessToken)); printf("Credentials saved to %s\n", $credentialsPath); } $client->setAccessToken($accessToken); // Refresh the token if it's expired. if ($client->isAccessTokenExpired()) { $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()); file_put_contents($credentialsPath, json_encode($client->getAccessToken())); } return $client; } /** * Expands the home directory alias '~' to the full path. * @param string $path the path to expand. * @return string the expanded path. */ function expandHomeDirectory($path) { $homeDirectory = getenv('HOME'); if (empty($homeDirectory)) { $homeDirectory = getenv('HOMEDRIVE') . getenv('HOMEPATH'); } return str_replace('~', realpath($homeDirectory), $path); } // Get the API client and construct the service object. $client = getClient(); $service = new Google_Service_Calendar($client); // Print the next 10 events on the user's calendar. $calendarId = 'primary'; $optParams = array( 'maxResults' => 10, 'orderBy' => 'startTime', 'singleEvents' => true, 'timeMin' => date('c'), ); $results = $service->events->listEvents($calendarId, $optParams); if (empty($results->getItems())) { print "No upcoming events found.\n"; } else { print "Upcoming events:\n"; foreach ($results->getItems() as $event) { $start = $event->start->dateTime; if (empty($start)) { $start = $event->start->date; } printf("%s (%s)\n", $event->getSummary(), $start); } } ?>