【发布时间】:2017-12-15 19:33:46
【问题描述】:
我正在使用 python 客户端库向 Google Calendar API 发出请求。它工作正常,但我没有得到日历上的所有事件。但是,如果我查看 API 资源管理器,我会以不同的格式获得所有内容。例如,API 资源管理器包含我需要的“摘要”键。这是为什么呢?
credentials = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACCOUNT_JSON_FILE_PATH, scopes)
http_auth = credentials.authorize(Http())
calendar = build('calendar', 'v3', credentials=credentials)
currentTime = datetime.datetime.now()
maxTime = currentTime + relativedelta(months=+1)
#do this to get all events on this day
maxTime = maxTime.replace(minute=59, hour=23, second=59)
currentTime = currentTime.isoformat('T') + '-06:00'
maxTime = maxTime.isoformat('T') + '-06:00'
response = calendar.events().list(calendarId="*******", singleEvents=True, maxResults=2500, showHiddenInvitations=True, timeMin=currentTime, timeMax=maxTime).execute()
return JsonResponse(response)
【问题讨论】:
标签: python django api google-api google-calendar-api