Google 日历会议 link 未通过 Google 日历 API (PHP) 自动创建

Google calendar meet link not being created automatically via Google Calendar API (PHP)

Google 日历会议 link 未通过 Google 日历 PHP API 自动创建。 Google 日历 API 已停止自动创建环聊会议 link。相同的代码在几个月前工作但并非没有。

代码

$client = getClient();
$service = new Google_Service_Calendar($client);
$event = new Google_Service_Calendar_Event(array(
  'summary' => $summary, //'Google Calendar summary',
  'location' => $location, //'USA',
  'description' => $description, //'Book Room',
  'start' => array(
    'dateTime' => $sessionStartTime,//'2018-08-16T14:30:00-00:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'end' => array(
    'dateTime' => $sessionEndTime,//'2018-08-16T14:30:00-01:00',
    'timeZone' => 'America/Los_Angeles',
  ),
  'attendees' => array(
    array('email' => $attendeesEmailNEW,'resource' => true),
  ),
  'reminders' => array(
    'useDefault' => FALSE,
    'overrides' => array(
      array('method' => 'popup', 'minutes' => 10),
    ),
  ),
));
    
$calendarId = 'primary';        
$event = $service->events->insert($calendarId, $event);
$createdID = $event->getId();   


        

解决方案

为了在活动中创建会议数据属性,您必须发送激活 ConferenceDataVersion 标志的请求。

conferenceDataVersion : 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. Acceptable values are 0 to 1, inclusive.

要在 PHP 中传递此设置,您可以使用以下指令:

 $service->events->insert($calendarId, $event, ['conferenceDataVersion' => 1]);      

设置此标志时,您还必须创建名为 conferenceData.createRequest

的事件 属性

The conference-related information, such as details of a Google Meet conference. To create new conference details use the createRequest field. To persist your changes, remember to set the conferenceDataVersion request parameter to 1 for all event modification requests.

示例:

"conferenceData" => [
        "createRequest" => [
          "conferenceSolutionKey" => [
            "type" => "hangoutsMeet"
          ],
          "requestId" => "123"
        ]
      ]

参考

Create Events

Calendar API Event insert