我正在使用 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);