我正在尝试编写一个可以将事件添加到Google日历的应用程序。
有一个非常整洁的网站,可让您使用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"
}
Run Code Online (Sandbox Code Playgroud)
只是一个自插:
有适用于 Python的Google Calendar Simple API (gcsa)(由我编写)。它更简单,更Pythonic,面向对象。它为您处理凭据、JSON 格式、日期时间/时区、重复发生等。这是文档。
检查所有 Python 示例的文档,例如,这里展示了如何创建事件:https ://developers.google.com/google-apps/calendar/v3/reference/events/insert