I'm successfully retrieving Calendar Event Attendees using the following code gist:
require_once __DIR__ . '/vendor/autoload.php';
putenv("GOOGLE_APPLICATION_CREDENTIALS=" . __DIR__ . '/mt-service-account.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setApplicationName("APP NAME");
$client->setSubject("<APPROPRIATE_USER_EMAIL>");
$client->setScopes([
'https://www.googleapis.com/auth/calendar'
]);
$calendarService = new Google_Service_Calendar($client);
$optParams = array(
'singleEvents' => true,
'orderBy' => 'startTime'
);
$events = $calendarService->events->listEvents('<APPROPRIATE_CALENDAR_ID>', $optParams);
foreach ($events->getItems() as $event) {
print_r($event->getAttendees());
}
However, as can be seen in the response, no Display Name is returned.
Array
(
[0] => Google_Service_Calendar_EventAttendee Object
(
[additionalGuests] =>
[comment] =>
[displayName] =>
[email] => [email protected]
[id] =>
[optional] =>
[organizer] =>
[resource] =>
[responseStatus] => needsAction
[self] =>
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
)
The attendee in question is a Contact of the event creator and the Contact's name and email appear in the type assist field when creating an event.
UPDATE NB Events are not created via API. They're created via Google Calendar (i.e. in browser). The attendees are added by typing the attendee's name in the Add Attendee field (Google type-assist found the Contact). The aim is to retrieve programmatically (i.e. with API) event details created by our G Suite Calendar users