问题描述
我需要实现一个 javascript 项目,该项目根据登录的用户创建新的 google meet,并将事件添加到日历并获取 google meet 的 url.如何在 JS 中使用 Google Calendar API 创建新的 google meet.
I need implement a javascript project that creates a new google meet according to the user signed in and adds the event to the calendar and gets the url of the google meet. How can i create a new google meet using Google Calendar API in JS.
推荐答案
答案:
您需要在创建日历时使用事件资源的 conferenceData.createRequest
参数.事件:插入请求以将 Meet 链接添加到日历事件.
Answer:
You need to use the conferenceData.createRequest
parameter of the Events resource when creating a Calendar.Events: insert request to add a Meet link to a Calendar Event.
conferenceDataVersion
: 整数
API 客户端支持的会议数据版本号.版本 0 假定不支持会议数据并忽略事件正文中的会议数据.版本 1 支持复制 ConferenceData 以及使用会议数据的 createRequest 字段创建新会议.默认值为 0.可接受的值为 0
到 1
(含).
conferenceData.createRequest
: 嵌套对象
生成新会议并将其附加到事件的请求.数据是异步生成的.要查看数据是否存在,请检查 status
字段.
需要 conferenceSolution
和至少一个 entryPoint
或 createRequest
.
Either conferenceSolution
and at least one entryPoint
, or createRequest
is required.
conferenceData.createRequest.conferenceSolutionKey.type
: string
会议解决方案类型.
如果客户端遇到不熟悉的或空的类型,它应该仍然能够显示入口点.但是,它应该禁止修改.
If a client encounters an unfamiliar or empty type, it should still be able to display the entry points. However, it should disallow modifications.
可能的值是:
- "
eventHangout
"面向消费者的环聊 (http://hangouts.google.com) - "
eventNamedHangout
"适用于 G Suite 用户的传统版环聊 (http://hangouts.google.com) - "
hangoutsMeet
"对于 Google Meet (http://meet.google.com) - "
addOn
"适用于 3P 会议提供商
- "
eventHangout
" for Hangouts for consumers (http://hangouts.google.com) - "
eventNamedHangout
" for classic Hangouts for G Suite users (http://hangouts.google.com) - "
hangoutsMeet
" for Google Meet (http://meet.google.com) - "
addOn
" for 3P conference providers
conferenceData.createRequest.requestId
: string
客户端为此请求生成的唯一 ID.客户端应为每个新请求重新生成此 ID.如果提供的 ID 与前一个请求相同,则该请求将被忽略.
根据这些信息,我们可以生成一个带有 Meet 链接的日历活动创建请求作为会议解决方案.
With this information we can generate a Calendar Event creation request with a Meet link as the conference solution.
gapi.client.calendar.events.insert({
"calendarId": "primary",
"conferenceDataVersion": 1,
"resource": {
"end": {
"date": "2020-10-24"
},
"start": {
"date": "2020-10-23"
},
"conferenceData": {
"createRequest": {
"conferenceSolutionKey": {
"type": "hangoutsMeet"
},
"requestId": "some-random-string"
}
},
"summary": "titles are cool"
}
});
注意:为了生成 Meet 链接,您必须设置 conferenceData.createRequest.requestId
到任意随机字符串.对于您希望创建的每个新会面链接,您必须在请求中使用不同的字符串.
NB: In order for a Meet link to be generated, you must set conferenceData.createRequest.requestId
to any random string. For each new meet link you wish to create, you must use a different string in the request.
这篇关于如何使用谷歌日历 api 创建一个新的谷歌会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!