如何通过 Google Apps 脚本获取 Google 日历的 "Location" 设置?
How to get Google calendar's "Location" setting via Google Apps Script?
创建 Google 日历或通过 UI 修改其设置时,有一个“位置”字段。我想通过 Google Apps Script (GAS) 获取该字段的值。
不幸的是,它似乎没有记录或未通过 the GAS Calendar API 公开。我已经搜索了网络以及 SO,但我想确保我没有忽略某些东西。
请注意:我指的不是活动地点,而是日历本身的 "Location" 字段,它是通过 [=25= 输入的] 在 UI.
使用 Calendar Service in Google Apps Script there are two methods for setting location. With the createEvent()
方法,您可以在 options
参数中包含位置和其他元数据:
// Creates an event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
new Date('July 20, 1969 20:00:00 UTC'),
new Date('July 20, 1969 21:00:00 UTC'),
{location: 'The Moon'});
Logger.log('Event ID: ' + event.getId());
或者 setLocation()
方法 CalendarEvent
例如
// Creates an event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
new Date('July 20, 1969 20:00:00 UTC'),
new Date('July 20, 1969 21:00:00 UTC'));
event.setLocation('The Moon');
Logger.log('Event ID: ' + event.getId());
尝试使用 Advanced Calendar Service:
The advanced Calendar service allows you to use the public Google Calendar API in Apps Script. Much like Apps Script's built-in Calendar service, this API allows scripts to access and modify the user's Google Calendar, including additional calendars that the user is subscribed to. In most cases, the built-in service is easier to use, but this advanced service provides a few extra features, including setting the background color for individual events.
然后阅读 Calendars 参考资料。
资源表示:
{
"kind": "calendar#calendar",
"etag": etag,
"id": string,
"summary": string,
"description": string,
"location": string,
"timeZone": string
}
注:
location - Geographic location of the calendar as free-form text. Optional.
这意味着您可以获取或不获取位置(如果未设置)。
还有 Calendars: insert and Calendars: get 试试这个 API 看看日历 - 位置如何工作。
希望对您有所帮助。
创建 Google 日历或通过 UI 修改其设置时,有一个“位置”字段。我想通过 Google Apps Script (GAS) 获取该字段的值。
不幸的是,它似乎没有记录或未通过 the GAS Calendar API 公开。我已经搜索了网络以及 SO,但我想确保我没有忽略某些东西。
请注意:我指的不是活动地点,而是日历本身的 "Location" 字段,它是通过 [=25= 输入的] 在 UI.
使用 Calendar Service in Google Apps Script there are two methods for setting location. With the createEvent()
方法,您可以在 options
参数中包含位置和其他元数据:
// Creates an event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
new Date('July 20, 1969 20:00:00 UTC'),
new Date('July 20, 1969 21:00:00 UTC'),
{location: 'The Moon'});
Logger.log('Event ID: ' + event.getId());
或者 setLocation()
方法 CalendarEvent
例如
// Creates an event for the moon landing and logs the ID.
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing',
new Date('July 20, 1969 20:00:00 UTC'),
new Date('July 20, 1969 21:00:00 UTC'));
event.setLocation('The Moon');
Logger.log('Event ID: ' + event.getId());
尝试使用 Advanced Calendar Service:
The advanced Calendar service allows you to use the public Google Calendar API in Apps Script. Much like Apps Script's built-in Calendar service, this API allows scripts to access and modify the user's Google Calendar, including additional calendars that the user is subscribed to. In most cases, the built-in service is easier to use, but this advanced service provides a few extra features, including setting the background color for individual events.
然后阅读 Calendars 参考资料。
资源表示:
{
"kind": "calendar#calendar",
"etag": etag,
"id": string,
"summary": string,
"description": string,
"location": string,
"timeZone": string
}
注:
location - Geographic location of the calendar as free-form text. Optional.
这意味着您可以获取或不获取位置(如果未设置)。
还有 Calendars: insert and Calendars: get 试试这个 API 看看日历 - 位置如何工作。
希望对您有所帮助。