使用python删除Google日历事件-获取事件ID [英] Deleting a google calendar event with python - getting Event ID

查看:46
本文介绍了使用python删除Google日历事件-获取事件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在这里遵循了python的python快速入门指南:

I have recently followed the python quick start guide for python here:

https://developers.google.com/calendar/quickstart/python

并且已成功将一些对象添加到我的Google日历中.然后,我尝试使用以下方法删除事件:

And have successfully added some objects to my google calendar. I am then trying to delete the events, using:

service.events().delete(calendarId='primary', eventId='eventId').execute()

尽管这在理想情况下可行,但我找不到获取任何事件的事件ID的方法.如何使用python

While this would ideally work, I can't find a way to get the event ID of any of my events. How am I able to get/set my google calendar event Ids using python

推荐答案

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

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":"..."

}

这篇关于使用python删除Google日历事件-获取事件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆