I'm trying to understand how I can generate and attach to a Google Calendar Event a Google Meet istance in PHP.
The documentation (https://developers.google.com/calendar/create-events#conferencing) is not clear about this part, the classes and methods for PHP are documented (https://developers.google.com/resources/api-libraries/documentation/calendar/v3/php/latest/class-Google_Service_Calendar_CreateConferenceRequest.html) so they exist. In the documentation there is a javacript example but I don't get how to translate it into php code.
I did some googling but no one else seems to had this necessity before.
UPDATE: I think I've found the problem. The javascript documentation reports that the setDocumentDataVersion(1) is required to allow to process the Meetings.
Here a brief doc about its use:
Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0.
This method doesn't seem to exist in the PHP API, so I cannot set it to 1. That's may why my code fail to attach a google meet to my event.
Here my test code. Till here it works fine and it creates an event in my calendar.
# Booking
$calendarId = 'test@group.calendar.google.com'; #
$event = new Google_Service_Calendar_Event();
$event->setSummary('Test');
$event->setDescription('Test Test');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2020-11-30T19:00:00+01:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2020-11-30T19:20:00+01:00');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('mytestemail@testtest.com');
// ...
$attendees = array($attendee1,
// ...
);
$event->attendees = $attendees;
#Try to create a Google Meet and attach it to event
$solution_key = new Google_Service_Calendar_ConferenceSolutionKey();
$solution_key->setType("hangoutsMeet");
$confrequest = new Google_Service_Calendar_CreateConferenceRequest();
$confrequest->setRequestId("3whatisup3");
$confrequest->setConferenceSolutionKey($solution_key);
$confdata = new Google_Service_Calendar_ConferenceData();
$confdata->setCreateRequest($confrequest);
$event->setConferenceData($confdata);
$createdEvent = $service->events->insert($calendarId, $event);
Any suggestions?
I believe your goal and situation as follows.
In order to add Google Meet to for your script, conferenceDataVersion
is set. In this case, it seems that the insert method is insert( string $calendarId, Google_Service_Calendar_Event $postBody, array $optParams = array() )
. So please modify your script as follows.
$createdEvent = $service->events->insert($calendarId, $event);
$createdEvent = $service->events->insert($calendarId, $event, array('conferenceDataVersion' => 1));