Skip to content

Instantly share code, notes, and snippets.

@ltanase77
Created May 27, 2020 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ltanase77/3a75725745a38fe6ec03ae3a3ecd85ad to your computer and use it in GitHub Desktop.
Save ltanase77/3a75725745a38fe6ec03ae3a3ecd85ad to your computer and use it in GitHub Desktop.
try {
$client = new Google_Client();
//$client->useApplicationDefaultCredentials();
$client->setAuthConfig(path/to/credentials_file);
$client->setApplicationName([appName]);
$client->addScope(Google_Service_Calendar::CALENDAR);
$client->setAccessType("offline");
$query = $this->files->get_file_by($file, "file_number");
if (is_array($query)) {
$service = new Google_Service_Calendar($client);
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Termen instanță',
'location' => $query[0]['court'],
'description' => 'Termen în dosarul ' . $query[0]['file_number'],
'start' => array(
'dateTime' => $query[0]['last_hearing'] . 'T08:30:00',
'timeZone' => 'Europe/Bucharest',
),
'end' => array(
'dateTime' => $query[0]['last_hearing'] . 'T12:00:00',
'timeZone' => 'Europe/Bucharest',
),
));
$calendarId = 'primary';
$result = $service->events->insert($calendarId, $event);
print_r ($result);
}
} catch (Exception $e) {
//log_message('error', $e['message']);
echo $e;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment