如何使用API​​从Google日历获取事件

时间:2019-04-08 08:07:08

标签: python google-calendar-api

如果我在Google Calender中写了一些活动 例如:3到4个事件我如何启动python程序以使用Google API提取所有这些事件?

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

print event['summary']

1 个答案:

答案 0 :(得分:0)

步骤1。您需要日历ID。

步骤2。您需要Google凭据。这将启用Google Calendar API的功能

#this code you can use at google app engine
def get_service():
    from googleapiclient.discovery import build
    from oauth2client.client import GoogleCredentials
    credentials = GoogleCredentials.get_application_default()
    service = build('calendar', 'v3', credentials=credentials)
    return service 

step3然后调用事件列表功能

 service = get_service()
 events = service.events().list(calendarId='calendarId').execute()

引用https://developers.google.com/calendar/v3/reference/events/list