如何在GS中使用扩展属性插入Google事件?
我想在Google script = .gs文件中添加 /插入具有扩展属性的新事件。
我找到了日历api的代码示例 - evestion insert - 见下文。但是该代码使用JavaScript客户端库。我希望代码从GS文件运行。我试图修改,但没有起作用。
使用代码时,我希望能够指定任何日历。不仅是“主要”。
// Refer to the JavaScript quickstart on how to setup the environment:
// https://developers.google.com/calendar/quickstart/js
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.
var event = {
'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': {
'dateTime': '2015-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles'
},
'end': {
'dateTime': '2015-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles'
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': '[email protected]'},
{'email': '[email protected]'}
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10}
]
}
};
var request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': event
});
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink);
});
有人可以解释私人和共享扩展属性之间的区别吗?
我能够使用以下代码创建新事件,但看起来它不会存储扩展属性。
function getCalendar() {
var calendarId = '[email protected]'
var calendar = CalendarApp.getCalendarById(calendarId)
Logger.log('The calendar is named "%s".', calendar.getName());
var eventOption = {
location: 'The Moon',
description: 'link na akci je https://us02web.zoom.us/j/83314336043',
extendedProperties: { // Extended properties of the event.
private: { // Properties that are private to the copy of the event that appears on this calendar.
creator: "Radek", // The name of the private property and the corresponding value.
},
}
}
var event = calendar.createEvent('test event from the script',
new Date(),
new Date(),
eventOption
);
var eventId = event.getId().replace(/@.*/,'') // // Remove @google.com from eventId
Logger.log('Event ID: ' + eventId)
calendarId = 'primary'
var eventSaved = Calendar.Events.get(encodeURIComponent(calendarId), eventId)
var testEx = event.extendedProperties
var test = event.extendedProperties.private["creator"];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题1:
官方文件显示如下。
例如,当创建一个新事件,并使用
extendedProperties.private
andextendedProperties.shared
通过包括与会者,您可以看到两个值。但是,与会者只能看到ExtendedProperties.shared
的值。这种解释有用吗?
问题2的答案:
当我看到
createEvent方法的正式文档(标题,开始时间,末日,选项)
时,似乎options
没有ExtendedProperties 。 ref 我认为这是您问题的原因。如果要创建一个新事件,包括
extendedProperties.private
和ExtendedProperties.shared
的值,如何使用高级Google Services的日历API?示例脚本如下。
extendedProperties.private
和extendedProperties.shared
的两个值。ExtendedProperties.shared
的值。参考:
Answer for question 1:
The official document says as follows.
For example, when a new event is created with the values of
extendedProperties.private
andextendedProperties.shared
by including the attendees, you can see both values. But, the attendees can see only the value ofextendedProperties.shared
.Is this explanation useful?
Answer for question 2:
When I saw the official document of the method of
createEvent(title, startTime, endTime, options)
, it seems thatoptions
has no property ofextendedProperties
. Ref I thought that this is the reason for your issue. If you want to create a new event including the values ofextendedProperties.private
andextendedProperties.shared
, how about using Calendar API of Advanced Google services?The sample script is as follows.
extendedProperties.private
andextendedProperties.shared
.extendedProperties.shared
.References:
有人可以解释私人和共享扩展属性之间的区别吗?
基于文档> documentation ,共享的扩展属性是可见的,而与会者可见且可在私人设置一位与会者的当地“副本”。
要使用应用程序脚本添加扩展属性,您可以使用高级日历服务< /a>。为此,您需要在应用程序脚本项目中添加“ Google Calendar API”服务,在屏幕的左侧,单击“服务”旁边的“+”,搜索“ Google Calendar api”,请单击它并单击“添加”。
完成上述步骤后,您可以测试我创建的示例。
Could someone please explain the difference between private and shared extended properties?
Based on documentation, shared extended properties are visible and editable by attendees while private set on one attendee's local "copy" of the event.
To add extended properties to events with Apps Script, you can do it with the advanced Calendar service. For this, you need to add the “Google Calendar API” service in your Apps Script project, on the left side of the screen, click on the “+” next to “Services”, search for “Google Calendar API”, click on it and click “Add”.
After completing the steps mentioned above, you can test this script I created as an example.