且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检索已删除的日历事件?

更新时间:2023-02-16 19:24:33

您可以使用Calendar API v3。通过启用高级Google服务的日历API和Google API控制台,可以在Google Apps脚本中使用日历API v3。



如何使用它如下。


  1. 脚本编辑器,选择资源>高级Google服务

  2. 在出现的对话框中,点击Calendar API v3的开/关按钮
  3. 在对话框的底部,点击Google API控制台的链接。


  4. 在控制台中,点击进入过滤器框并键入API名称的一部分日历,然后在看到它时单击该名称。

  5. 在下一个屏幕上,单击启用API。
  6. 关闭Developers Console并返回脚本编辑器。在对话框中单击确定。您启用的高级服务现已在自动完成中可用。

  7. https://developers.google.com/apps-script/guides/services/advanced

    检索已删除事件列表的脚本如下所示。如果JSON响应。



    脚本:

      var response = Calendar.Events.list(
    CalendarId,{
    showDeleted:true,
    fields:items(id,summary)
    }
    );

    回应:

      {
    items:[
    {
    id:####,
    summary: test1
    },
    {
    id:####,
    summary:test2
    }
    ]
    }

    在此示例中,id和summary被设置为字段。如果您需要其他字段,请查看 https://developers.google。 COM /谷歌应用程序/日历/ V3 /参考/事件的。



    如果我误解了您的问题,我很抱歉。


    Is there a way to retrieve deleted calendar events in Google Apps Script? I'm trying to keep track of our rate of meeting cancellations. I can see deleted events in the calendar's Trash (folder?), but am unable to retrieve them using the CalendarApp's getEvents API.

    I've tried querying using:

    myCalndar.getEvents(some_days_past, now, {search: "in:Trash"});
    

    as well as numerous variations of search strings and optional properties, but none return any results.

    Any ideas?

    For the record, I've been going by the API documented here: https://developers.google.com/apps-script/reference/calendar/calendar-app

    You can use "Calendar API v3". "Calendar API v3" can be used at Google Apps Script by enabling Calendar API of Advanced Google services and of Google API Console.

    How to use it is as follows.

    1. In the script editor, select Resources > Advanced Google services

    2. In the dialog that appears, click the on/off switch for Calendar API v3

    3. At the bottom of the dialog, click the link for the Google API Console.

    4. In the console, click into the filter box and type part of the name of the API "Calendar", then click the name once you see it.

    5. On the next screen, click Enable API.

    6. Close the Developers Console and return to the script editor. Click OK in the dialog. The advanced service you enabled is now available in autocomplete.

    The detail information is https://developers.google.com/apps-script/guides/services/advanced.

    A script for retrieving a list of trashed events is as follows. Response if JSON.

    Script :

    var response = Calendar.Events.list(
      "CalendarId", {
        showDeleted: true,
        fields: "items(id,summary)"
      }
    );
    

    Response :

    {
      "items": [
        {
          "id": "####",
          "summary": "test1"
        },
        {
          "id": "####",
          "summary": "test2"
        }
      ]
    }
    

    At this sample, id and summary are set as fields. If you want other fields, please check https://developers.google.com/google-apps/calendar/v3/reference/events.

    If I misunderstand your question, I'm sorry.