如何使用API从googlecalender获取事件

2024-04-23 23:21:28 发布

您现在位置:Python中文网/ 问答频道 /正文

如果我在谷歌日历上写一些事件 例如:3到4个事件如何启动python程序来使用googleapi获取所有这些事件?你知道吗

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

print event['summary']

Tags: 程序eventexecutegetservice事件summaryevents
1条回答
网友
1楼 · 发布于 2024-04-23 23:21:28

第一步。你需要日历id

第二步。你需要谷歌认证。它支持googlecalendarapi的函数

#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 

步骤3然后调用事件列表函数

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

参考https://developers.google.com/calendar/v3/reference/events/list

相关问题 更多 >