Example #1
0
<?php

// Check if authenticated
if (!isAuthenticatedWithGoogle()) {
    http_response_code(500);
    exit;
}
// Calendar ID
if (isset($_POST['calendarId'])) {
    $calendarId = $_POST['calendarId'];
} else {
    $calendarId = 'primary';
}
// Event ID
if (!isset($_POST['eventId'])) {
    http_response_code(500);
    exit;
}
$eventId = $_POST['eventId'];
// Google library
require_once __DIR__ . '/../../../google.php';
// Delete event
$googleCalendarService->events->delete($calendarId, $eventId);
Example #2
0
        if ($y === $toDate['year'] && $m === $toDate['month']) {
            $dayFinish = $toDate['day'];
            $dayFinish = max($toDate['day'], 1);
            $dayFinish = min($toDate['day'], $daysInMonth);
        }
        for ($d = $dayStart; $d <= $dayFinish; $d++) {
            $data[date('Y-m-d', strtotime($y . '-' . $m . '-' . $d))] = [];
        }
    }
}
/**
 * Load Google Events
 *
 * Gets a list of all events for all calendars
 */
if (isAuthenticatedWithGoogle() && isset($_GET['timeZone'])) {
    require_once __DIR__ . '/../../google.php';
    // Options
    $options = ['orderBy' => 'startTime', 'singleEvents' => true];
    if (isset($_GET['fromDate'])) {
        $options['timeMin'] = $_GET['fromDate'] . 'T00:00:00.000' . $_GET['timeZone'];
    }
    if (isset($_GET['toDate'])) {
        $options['timeMax'] = $_GET['toDate'] . 'T23:59:59.000' . $_GET['timeZone'];
    }
    // Get list of all calendars
    $response = $googleCalendarService->calendarList->listCalendarList();
    $response = $response->toSimpleObject();
    $calendars = $response->items;
    // For each calendar
    foreach ($calendars as $calendar) {