【问题标题】:Looking for a better python Google Calendar API example寻找更好的 python Google Calendar API 示例
【发布时间】:2012-05-23 02:26:46
【问题描述】:

我正在尝试编写一个可以将事件添加到谷歌日历的应用程序。
有一个非常简洁的网站可以让您使用 API。 http://code.google.com/apis/explorer/#_s=calendar&_v=v3&_m=events.insert

使用该网站,我能够使用以下内容构建日历事件 东西。我很难将它翻译成python。假设我已经通过 oauth 进行了身份验证,我该如何使用 python 代码执行此操作?看来我必须构建一个 json 字符串并以某种方式将其转换为 http 请求。我不知道该怎么做。

谁能提供一个例子来说明如何用 Python API?

非常感谢!

POST
https://www.googleapis.com/calendar/v3/calendars/my_calendar_id_string/events?pp=1&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.ANOTHERBIGSLONGTRINGHEREFfxCTiKMIR_bDui
X-JavaScript-User-Agent:  Google APIs Explorer

{
"start": {
"dateTime": "2012-05-24T14:00:00-06:00"
},
"end": {
"dateTime": "2012-05-24T18:00:00-06:00"
},
"description": "My Description"
}

【问题讨论】:

  • Interesting link 适用于任何尝试使用 API 资源管理器并需要格式化日期时间字符串的人。

标签: python google-api


【解决方案1】:

只是一个自插式:

有用于 Python 的 Google Calendar Simple API (gcsa)(由我开发(upd: 和其他贡献者))。它更简单,更 Pythonic,面向对象。它为您处理凭证、JSON 格式、日期时间/时区、重复周期等。这是Documentation

【讨论】:

  • 这是一项非常了不起的工作,它创建了一个更加友好的 API,让不熟悉原始 API 的人能够在编写可理解的代码的同时快速简洁地完成工作。强烈推荐!
【解决方案2】:

查看所有 Python 示例的文档,例如,这里展示了如何创建事件:https://developers.google.com/google-apps/calendar/v3/reference/events/insert

【讨论】:

    【解决方案3】:

    看到this article 有大量截图的节目。

    另外,this GitHub repo 有很多例子。

    【讨论】:

      猜你喜欢
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 2015-02-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-05
      • 2014-04-30
      • 2020-04-09
      相关资源
      最近更新 更多