-------------------
require_once __DIR__ . '/vendor/autoload.php';
// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Calendar($client);
// Define the event details.
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Test Event',
'location' => 'Test Location',
'description' => 'Test Description',
'start' => array(
'dateTime' => '2022-01-01T09:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'end' => array(
'dateTime' => '2022-01-01T17:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
));
// Insert the event into the calendar.
$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
---------------------------------------
require_once __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName('My Calendar App');
$client->setScopes(Google_Service_Calendar::CALENDAR);
$client->setAuthConfig('credentials.json');
$client->setAccessType('offline');
$calendarService = new Google_Service_Calendar($client);
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Test Event',
'location' => 'My House',
'description' => 'Testing the calendar API',
'start' => array(
'dateTime' => '2022-03-28T09:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'end' => array(
'dateTime' => '2022-03-28T17:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'recurrence' => array(
'RRULE:FREQ=DAILY;COUNT=2'
),
'attendees' => array(
array('email' => 'attendee1@example.com'),
array('email' => 'attendee2@example.com'),
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'email', 'minutes' => 24 * 60),
array('method' => 'popup', 'minutes' => 10),
),
),
));
$calendarId = 'primary';
$event = $calendarService->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);
------------------