我想在环聊会议中使用Google Calendar API插入事件。
我尝试使用ConferenceData键,但没有结果。
执行此操作的正确方法是什么?
我已经这样做了:
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' => '[email protected]'),
),
'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: %s\n', $event->htmlLink);
printf('Hangout link: %s\n', $event->hangoutLink);
我正在使用JavaScript,但是the APIs are the same。我必须在conferenceDataVersion
中设置insert()
,并在createRequest
中使用了conferenceData
,如下所示:
conferenceData: {
createRequest: {
requestId: '123456790',
conferenceSolutionKey: {
type: 'hangoutsMeet',
},
status: {
statusCode: 'success'
}
},
}
我还发现自己在无尽的搜索和尝试中。我几乎用立即可用的NodeJS API破解了我的用例。
这就是我的工作方式:首先,您需要执行insert方法,然后您可以使用patch方法添加会议。
这是我的工作示例:
$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);
希望它也对您有效。