gpt4 book ai didi

php - 使用 Google Calendar API 插入带有环聊 session 的事件

转载 作者:行者123 更新时间:2023-12-01 22:33:32 25 4
gpt4 key购买 nike

我想通过环聊 session 使用 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' => '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: %s\n', $event->htmlLink);
printf('Hangout link: %s\n', $event->hangoutLink);

最佳答案

我也发现自己在无休止的寻找和尝试中。我几乎用立即可用的 NodeJS API 破解了我的用例。

这就是我的工作方式:首先您需要执行插入方法,然后您可以使用补丁方法添加 session 。

这是我的工作示例:

$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);

希望它也适合您。

关于php - 使用 Google Calendar API 插入带有环聊 session 的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57217719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com