如何使用Python通过API v3创建Google日历事件

如何使用Python通过API v3创建Google日历事件,python,google-api,google-calendar-api,google-api-client,google-api-python-client,Python,Google Api,Google Calendar Api,Google Api Client,Google Api Python Client,下面的官方页面给出了如何使用Python创建事件的示例。 他们给出的代码如下所示: event = { 'summary': 'Appointment', 'location': 'Somewhere', 'start': { 'dateTime': '2011-06-03T10:00:00.000-07:00' }, 'end': { 'dateTime': '2011-06-03T10:25:00.000-07:00' }, 'attendees'

下面的官方页面给出了如何使用Python创建事件的示例。

他们给出的代码如下所示:

event = {
  'summary': 'Appointment',
  'location': 'Somewhere',
  'start': {
    'dateTime': '2011-06-03T10:00:00.000-07:00'
  },
  'end': {
   'dateTime': '2011-06-03T10:25:00.000-07:00'
  },
  'attendees': [
  {
    'email': 'attendeeEmail',
    # Other attendee's data...
  },
  # ...
  ],
}

created_event = service.events().insert(calendarId='primary', body=event).execute()

print created_event['id']
但是,上面的示例并没有说明如何建立连接和创建
服务
变量。由于我已将日历设置为公共日历,因此我认为创建
服务将非常容易


有人知道如何建立连接吗?

我在弄清楚如何将google calendar api与OAuth等一起使用时遇到了一些困难。我最终使一切正常工作,并在此过程中编写了一个非常简单易用的包。我将它发布到github,可以使用“pip install gback”从pypi安装它。该文档还提供了有关google帐户设置的说明

下面是一个示例snipbit,用于将约会添加到日历中

from gback import GCalSession

# print the output will display the appiointment url.
# 'Marc' is the name of the calendar used.

session = GCalSession('~/gback.oauth')
des='Write a simpler way to use the google calendar api.'
print session['Marc'].add('Write Python code.', '20150430', des=des)

享受吧,Marc,我建议,对于仍在寻找更好的谷歌日历API的人来说。当我在理解和使用官方API方面遇到巨大问题时,我为自己开发了(并且还在开发)这个库。

请按照这里的说明操作:有完整的python代码示例。@jungyoungwak这就是我要找的。谢谢你提供的信息。@JunYoung Gwak你应该把它作为一个答案发布。不过,这些示例都是Web流身份验证的示例。@AMS Stackoverflow的策略是不写仅链接的应答。我评论的链接基本上回答了这个问题,除此之外没有什么可添加的。因此,我应该对此进行评论,而不是回答。