简体   繁体   English

Google Calendar API返回的结果与API Explorer不同

[英]Google calendar API returning different results than API explorer

I'm using the python client library to make a request to the Google Calendar API. 我正在使用python客户端库向Google Calendar API发出请求。 It works fine, but I'm not getting all of the events on the calendar. 它工作正常,但我没有在日历上获得所有事件。 However, if I view the API explorer, I get everything and in a different format. 但是,如果我查看API资源管理器,则会以不同的格式获得所有内容。 For example, the API explorer includes a "summary" key which I need. 例如,API资源管理器包括我需要的“摘要”键。 Why is that? 这是为什么?

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)

All the properties that the Calendar API explorer can be found in Resource representations including " summary ". 可以在资源表示形式中找到Calendar API Explorer的所有属性,包括“ summary ”。 Now to fetch all of that after a successful API request, be sure to specify ' * ' in your q parameter to tell Event.list that you want a complete response. 现在,要在成功的API请求后获取所有内容,请确保在q参数中指定' * ' ,以告知Event.list您需要完整的响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM