Google apps script 未定义“getCalendarById”

Google apps script 未定义“getCalendarById”,google-apps-script,Google Apps Script,没有定义给我getCalendarById的Code.gs有什么问题?另外,如果我添加CalendarApp。在getCalendarById方法前面,整个过程中断,URL只返回一个驱动器错误 解决方案: 我必须在getCalendarById前面添加CalendarApp,因为我看错了文档。在“授予访问权”一节下的文件中,我读到- 脚本不请求授权,如果它们…或者您以在脚本所有者的用户身份下运行的web应用程序的形式访问脚本 我是以我自己的身份运行脚本的,但没有意识到上面的引用意味着它将不会发布

没有定义给我getCalendarById的Code.gs有什么问题?另外,如果我添加CalendarApp。在getCalendarById方法前面,整个过程中断,URL只返回一个驱动器错误

解决方案: 我必须在getCalendarById前面添加CalendarApp,因为我看错了文档。在“授予访问权”一节下的文件中,我读到-

脚本不请求授权,如果它们…或者您以在脚本所有者的用户身份下运行的web应用程序的形式访问脚本

我是以我自己的身份运行脚本的,但没有意识到上面的引用意味着它将不会发布并获得授权,而不是它仍然需要您自己获得它。非常感谢Serge insas对我的巨大帮助、支持和理解

代码G.gs:

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index.html').setSandboxMode(HtmlService.SandboxMode.NATIVE);
}

function listEvents(dateSelected) {
  var calendar = getCalendarById('en.usa#holiday@group.v.calendar.google.com').getEventsForDay(new Date(dateSelected)); // if I put calendarapp. the whole thing returns an error from the URL

  Logger.log('Number of events: ' + calendar.length);
}
html:

getCalendarById是calendarApp服务的一种方法,正确的语法如下:

var calendar = CalendarApp.getCalendarById("xxxxxxxx");

请参见

当我添加CalendarApp部分时,web应用程序不会呈现,只会给我一个goolge驱动器错误。您是否已授权您的脚本?在中授权为“部署为web应用程序”,以我自己的身份运行,并且任何人都可以访问?抱歉,已离开。。。不,从脚本编辑器运行doGet以获得日历服务的授权,如果没有,则执行更多操作。此外,文档还说,如果它是一个专门为您自己的日历运行的Web应用程序。很抱歉延迟回复。尝试学习应用程序脚本让我非常沮丧。感谢您在这个问题和其他stackexchange问题上提供的帮助。
var calendar = CalendarApp.getCalendarById("xxxxxxxx");