【问题标题】:How to add specific exists Google Meet link when create calendar via Google Calendar API?通过 Google Calendar API 创建日历时如何添加特定的现有 Google Meet 链接?
【发布时间】:2021-09-27 02:10:36
【问题描述】:

我正在使用 PHP 通过 Google Calendar API 在 Google Calendar 上创建一个活动,我可以在创建活动时自动创建 Meet 链接,但我想在创建活动时添加现有的 Meet 链接,但它不起作用。我尝试使用Google_Service_Calendar_Event::setHangoutLink() 来设置特定的Google Meet URL,但当我调用Google_Service_Calendar_Event::insert() 时不会受到影响

这是我的代码:

$client = $this->getClient();
$service = new \Google_Service_Calendar($client);

$calendarId = $this->calendarId;
$startTime = date(DATE_ATOM, $startTime);
$endTime = date(DATE_ATOM, $endTime);

$event = new \Google_Service_Calendar_Event();
$event->setSummary($title);

$startObj = new \Google_Service_Calendar_EventDateTime();
$startObj->setDateTime($startTime);
$startObj->setTimeZone('Asia/Ho_Chi_Minh');
$event->setStart($startObj);
$endObj = new \Google_Service_Calendar_EventDateTime();
$endObj->setDateTime($endTime);
$endObj->setTimeZone('Asia/Ho_Chi_Minh');
$event->setEnd($endObj);

$conferenceObj = new \Google_Service_Calendar_ConferenceData();

$entryPointObj = new Google_Service_Calendar_EntryPoint();
$entryPointObj->setAccessCode('<access code goes here>');
$entryPointObj->setMeetingCode('<meeting code goes here>');
$conferenceObj->setEntryPoints($entryPointObj);
        
$conferenceSolutionObj = new \Google_Service_Calendar_ConferenceSolution();
$conferenceSolutionObj->setIconUri(null);
$conferenceSolutionObj->setKey(new \Google_Service_Calendar_ConferenceSolutionKey());
$conferenceObj->setConferenceSolution($conferenceSolutionObj);

$conferenceRequestObj = new \Google_Service_Calendar_CreateConferenceRequest();
$requestId = strtolower(preg_replace('/\-?\s?\_?/', '', $title));
$conferenceRequestObj->setRequestId($requestId);
        
$conferenceSolutionKeyObj = new \Google_Service_Calendar_ConferenceSolutionKey();
$conferenceSolutionKeyObj->setType("hangoutsMeet");
$conferenceRequestObj->setConferenceSolutionKey($conferenceSolutionKeyObj);
$conferenceRequestObj->setStatus(new \Google_Service_Calendar_ConferenceRequestStatus());
$conferenceObj->setCreateRequest($conferenceRequestObj);

$event->setConferenceData($conferenceObj);
$event->setHangoutLink('<my google meet link...>');
$optionalConference = array('conferenceDataVersion' => 1);

$created_event = $service->events->insert($calendarId, $event,$optionalConference);
print_r($created_event);

【问题讨论】:

  • 您在运行此代码时是否遇到任何错误?
  • 不,不是,事件可以创建成功但不设置具体链接,只是api响应的链接
  • 您能否确认您通过了准确的会议代码?
  • @ale13 是的,我很确定。会议代码字符串的格式是什么?它们是否在代码中每 3 个字符后包含“-”?例如abc-def-ghiABCDEFGHI
  • 我很抱歉造成混乱,但您想要的无法实现。请检查我在下面提供的答案。

标签: php google-calendar-api google-meet


【解决方案1】:

看来你想达到的实际上是不可能的。

如果您查看日历 API 文档here,您可以看到hangoutLink 字段实际上是read-only。这实质上意味着您不能更改与创建的活动关联的 Meet 链接,也不能为其分配自定义链接。

hangoutLink > 指向与此事件相关的 Google+ 环聊的绝对链接。 只读

此外,setHangoutLink 方法似乎也揭示了这一点(在 Java 客户端库 here 中)。

但是,在这种情况下,您可以做的是在 Google 问题跟踪器 here 上给问题加注星标 ★。

参考

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多