我想使用 Google 日历 API 和环聊会议插入一个活动。
我尝试使用会议数据键,但没有结果。
正确的方法是什么?
我是这样做的:
function getClient()
{
...... ......
...... ......
return $client;
}
// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Calendar($client);
$conferenceDataArr = array(
'conferenceId' => 'aaa-bbb-ccc',
'conferenceSolution' => array(
'key' => array(
'type' => 'hangoutsMeet'
),
'name' => 'Reunión en VideoConferencia',
),
'entryPoints' => array(
'accessCode' => '55555',
'entryPointType' => 'video',
'label' => 'meet.google.com/aaa-bbbb-ccc',
'uri' => 'https://meet.google.com/aaa-bbbb-ccc'
)
);
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Google I/O 2015',
'location' => '800 Howard St., San Francisco, CA 94103',
'description' => 'A chance to hear more about Google's developer products.',
'start' => array(
'dateTime' => '2019-07-26T11:54:00',
'timeZone' => 'Europe/Madrid',
),
'end' => array(
'dateTime' => '2019-07-26T20:00:00',
'timeZone' => 'Europe/Madrid',
),
'attendees' => array(
array('email' => 'me@gmail.com'),
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'email', 'minutes' => 0)
),
),
'conferenceData' => $conferenceDataArr
));
$calendarId = 'primary';
$optParams = Array(
'sendNotifications' => true,
'sendUpdates' => 'all',
);
$event = $service->events->insert($calendarId, $event, $optParams);
printf('Event created: %sn', $event->htmlLink);
printf('Hangout link: %sn', $event->hangoutLink);
我也发现自己处于无休止的搜索和尝试中。我几乎用立即工作的 NodeJS API 破解了我的用例。
这就是我让它工作的方式:首先您需要执行插入方法,然后您可以使用补丁方法添加会议。
这是我的工作示例:
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Appointment',
'location' => 'Earth',
'description' => 'Hello world',
'start' => array(
'dateTime' => Carbon::now()->format('c'),
'timeZone' => 'Europe/Zurich',
),
'end' => array(
'dateTime' => Carbon::now()->addMinutes(15)->format('c'),
'timeZone' => 'Europe/Zurich',
)
));
$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s', $event->htmlLink);
$conference = new Google_Service_Calendar_ConferenceData();
$conferenceRequest = new Google_Service_Calendar_CreateConferenceRequest();
$conferenceRequest->setRequestId('randomString123');
$conference->setCreateRequest($conferenceRequest);
$event->setConferenceData($conference);
// ['conferenceDataVersion' => 1] is required!
$event = $service->events->patch($calendarId, $event->id, $event, ['conferenceDataVersion' => 1]);
printf('<br>Conference created: %s', $event->hangoutLink);
希望它也对你有用。
我正在使用JavaScript,但API是相同的。我必须在insert()
中设置conferenceDataVersion
,并在conferenceData
中使用了createRequest
,如下所示:
conferenceData: {
createRequest: {
requestId: '123456790',
conferenceSolutionKey: {
type: 'hangoutsMeet',
},
status: {
statusCode: 'success'
}
},
}