使用 Google Calendar API 插入带有环聊会议的活动

Ant*_*top 5 php google-calendar-api

我想使用 Google Calendar API 和环聊会议插入活动。

\n\n

我尝试使用conferenceData 键但没有结果。

\n\n

这样做的正确方法是什么?

\n\n

我是这样做的:

\n\n
\nfunction getClient()\n{\n...... ......\n...... ......\n    return $client;\n}\n\n// Get the API client and construct the service object.\n$client = getClient();\n$service = new Google_Service_Calendar($client);\n\n$conferenceDataArr = array(\n    \'conferenceId\' => \'aaa-bbb-ccc\',\n    \'conferenceSolution\' => array(\n        \'key\' => array(\n            \'type\' => \'hangoutsMeet\'\n        ),\n        \'name\' => \'Reuni\xc3\xb3n en VideoConferencia\',\n\n    ),\n    \'entryPoints\' => array(\n        \'accessCode\' => \'55555\',\n        \'entryPointType\' => \'video\',\n        \'label\' => \'meet.google.com/aaa-bbbb-ccc\',\n        \'uri\' => \'https://meet.google.com/aaa-bbbb-ccc\'\n    )\n);\n\n$event = new Google_Service_Calendar_Event(array(\n    \'summary\' => \'Google I/O 2015\',\n    \'location\' => \'800 Howard St., San Francisco, CA 94103\',\n    \'description\' => \'A chance to hear more about Google\\\'s developer products.\',\n    \'start\' => array(\n      \'dateTime\' => \'2019-07-26T11:54:00\',\n      \'timeZone\' => \'Europe/Madrid\',\n    ),\n    \'end\' => array(\n      \'dateTime\' => \'2019-07-26T20:00:00\',\n      \'timeZone\' => \'Europe/Madrid\',\n    ),\n    \'attendees\' => array(\n      array(\'email\' => \'me@gmail.com\'),\n    ),\n    \'reminders\' => array(\n      \'useDefault\' => FALSE,\n      \'overrides\' => array(\n        array(\'method\' => \'email\', \'minutes\' => 0)\n      ),\n    ),\n    \'conferenceData\' => $conferenceDataArr\n  ));\n\n  $calendarId = \'primary\';\n\n  $optParams = Array(\n    \'sendNotifications\' => true,\n    \'sendUpdates\' => \'all\',\n    );\n\n  $event = $service->events->insert($calendarId, $event, $optParams);\n  printf(\'Event created: %s\\n\', $event->htmlLink);\n  printf(\'Hangout link: %s\\n\', $event->hangoutLink);\n
Run Code Online (Sandbox Code Playgroud)\n

小智 5

我也发现自己在无尽的寻找和尝试中。我几乎用立即可用的 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);
Run Code Online (Sandbox Code Playgroud)

希望它也适合你。


imj*_*red 1

我使用的是 JavaScript,但API 是相同的。我必须设置conferenceDataVersionin myinsert()并使用 a createRequestin conferenceData,如下所示:

conferenceData: {
  createRequest: {
    requestId: '123456790',
    conferenceSolutionKey: {
      type: 'hangoutsMeet',
    },
    status: {
      statusCode: 'success'
    }
  },
}
Run Code Online (Sandbox Code Playgroud)