Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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