【问题标题】:Google calendar API returning different results than API explorerGoogle 日历 API 返回的结果与 API 资源管理器不同
【发布时间】: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


    【解决方案1】:

    日历 API 资源管理器的所有属性都可以在 Resource representations 中找到,包括“summary”。现在要在成功的 API 请求后获取所有这些,请务必在您的 q parameter 中指定 ' * ' 以告诉 Event.list 您想要完整的响应。

    【讨论】:

      猜你喜欢
      • 2017-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-19
      • 1970-01-01
      • 2019-06-04
      相关资源
      最近更新 更多