且构网

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

使用python删除Google日历事件-获取事件ID

更新时间:2023-12-03 14:20:16

使用以下方法创建事件时:

When you create an event using:

insert(calendarId=*, body=*, sendNotifications=None, supportsAttachments=None, sendUpdates=None, conferenceDataVersion=None, maxAttendees=None)

您可以在 body 部分中指定自己的事件ID.这是文档说:

You get to specify your own event id in the body section. Here is what the documentation says:

"id":"A String",#事件的不透明标识符.新建时单个事件或重复发生的事件,您可以指定其ID.提供的ID必须遵循以下规则:#-ID中允许的字符是base32hex编码中使用的字符,即小写字母a-v和数字0-9,请参阅第3.1.2节在RFC2938中#-ID的长度必须在5到1024个字符之间#-每个日历的ID必须是唯一的.由于系统是全球性的,因此我们无法保证该ID创建事件时将检测到冲突.尽量减少碰撞风险我们建议使用已建立的UUID算法例如RFC4122中描述的内容.#如果未指定ID,它将由服务器自动生成.#请注意,icalUID和id不相同,并且在事件创建时仅应提供其中之一.一个区别在他们的语义上是,在重复发生的事件中,一个事件的所有出现事件都具有不同的ID,而它们都共享相同的icalUID.

"id": "A String", # Opaque identifier of the event. When creating new single or recurring events, you can specify their IDs. Provided IDs must follow these rules: # - characters allowed in the ID are those used in base32hex encoding, i.e. lowercase letters a-v and digits 0-9, see section 3.1.2 in RFC2938 # - the length of the ID must be between 5 and 1024 characters # - the ID must be unique per calendar Due to the globally distributed nature of the system, we cannot guarantee that ID collisions will be detected at event creation time. To minimize the risk of collisions we recommend using an established UUID algorithm such as one described in RFC4122. # If you do not specify an ID, it will be automatically generated by the server. # Note that the icalUID and the id are not identical and only one of them should be supplied at event creation time. One difference in their semantics is that in recurring events, all occurrences of one event have different ids while they all share the same icalUIDs.

您可以存储此ID,以后再使用它删除事件.

You can store this id and later use it to delete the event.

正文可能如下:

{
    "attachments": [ 
      {
        "mimeType": "...", 
        "title": "...", 
        "fileUrl": "...", 
        "iconLink": "...", 
        "fileId": "...", 
      },
    ],
    "creator": { 
      "self": false, 
      "displayName": "...",
      "email": "...", 
      "id": "...", 
    },
    "organizer": { 
      "self": false, 
      "displayName": "...", 
      "email": "...", 
      "id": "...", 
    },
    "summary": "...",
    "id": "Your ID GOES HERE", 
    "hangoutLink":"..."

}