Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从Google日历事件中获取Google文档/atachment URL?_Javascript_Scripting_Google Calendar Api - Fatal编程技术网

Javascript 如何从Google日历事件中获取Google文档/atachment URL?

Javascript 如何从Google日历事件中获取Google文档/atachment URL?,javascript,scripting,google-calendar-api,Javascript,Scripting,Google Calendar Api,我有一个谷歌脚本: function moveHangoutLinks() { var calendarId = 'fzivolo@quid.com'; var now = new Date(); var events = Calendar.Events.list(calendarId, { timeMin: now.toISOString(), singleEvents: true, orderBy: 'startTime

我有一个谷歌脚本:

function moveHangoutLinks() {
    var calendarId = 'fzivolo@quid.com';
    var now = new Date();
    var events = Calendar.Events.list(calendarId, {
        timeMin: now.toISOString(),
        singleEvents: true,
        orderBy: 'startTime',
        maxResults: 10
    });
    if (events.items && events.items.length > 0) {
        for (var i = 0; i < events.items.length; i++) {
            var event = events.items[i];
            var d = event.description;
            if (!d)
                d = '';
            if (event.googleDocsLink && (d.indexOf('Hangout: ') == -1)) {
                // Logger.log (event.summary + ' - ' + event.hangoutLink + ' - ' + event.description);
                event.description = 'Hangout: ' + event.hangoutLink + '\n\n' + d;
                Calendar.Events.update(event, calendarId, event.id);
            }
        }
    } else {
        Logger.log('No events found.');
    }
}
它基本上在谷歌日历上获取每个事件的链接,并将其放在事件描述中

我想对任何Google文档附件也这样做,但是我找不到任何文档来知道事件对象中有哪些属性可用

我怎样做/在哪里可以找到文档?

试试看

成功的HTTP请求

GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events
将返回具有以下结构的响应体:

{
  "kind": "calendar#events",
  "items": [
    "attachments": [
    {
      "fileUrl": string,
      "title": string,
      "mimeType": string,
      "iconLink": string,
      "fileId": string
    }
    ]
  ]
}

其中attachments[].fileUrl是指向附件的URL链接。要添加Google驱动器文件附件,请使用与驱动器API中文件资源的alternateLink属性相同的格式。

谢谢!你看到这里有什么不对劲吗?由于某些原因,它似乎没有在描述中添加文档URL。请尝试使用参数supportsAttachments设置为true的更新事件。我找不到如何使用google脚本API启用此标志,顺便说一句,我不知道如何需要此标志。当我运行update命令时,数据已被提取。。。