【问题标题】:#next_sync_token fo Google Calendar Events always return nil#next_sync_token fo Google 日历事件总是返回 nil
【发布时间】:2015-11-30 12:56:03
【问题描述】:

我在日历中创建了 3 个事件,然后运行

response = @client.execute!(
   :api_method => @calendar_api.events.list,
   :parameters => {
     :calendarId => "primary",
     :maxResults => 10,
     :singleEvents => true,
     :orderBy => 'startTime'}
 )

我收到了 3 个项目,但在 response.data 上调用的 #next_sync_token 方法返回 nil(#next_page_token 也返回 nil,但在这种情况下它是正确的)。我尝试将 :fields 参数设置为“nextSyncToken”,但仍然没有。我还对这些事件进行了一些更新,#next_sync_token 仍然设置为零..我错了吗?也许我犯了一些错误? 仅在参数中使用calendarId 的调用也是如此。

【问题讨论】:

    标签: google-calendar-api google-api-ruby-client


    【解决方案1】:

    摆脱 orderBy。这没有记录,但如果您尝试使用 Google API,您会发现 nextSyncToken 没有与 orderBy: startTime 一起返回。

    在同一个问题上浪费了大量时间。

    【讨论】:

    • 这绝对是我的问题!非常感谢您发布此内容。 Google Calendar API 文档需要改进。
    • 谢谢你——永远找不到这个!
    • 哇。跛脚,谢谢分享。为我节省了多少时间。
    【解决方案2】:

    结果将只有最后一页上的下一个同步令牌。你需要遍历所有页面(直到 next_page_token nil),然后你会找到一个同步令牌。

    【讨论】:

    • 是的,这是真的,我知道这一点,但这里我只有 3 个事件,所以我只有 1 页,这是最后一页。在这种情况下,我认为 #next_sync_token 应该使用正确的令牌进行响应。我还看到 response.body 包含 nextSyncToken,所以该方法应该可以工作
    猜你喜欢
    • 2018-11-15
    • 2017-03-28
    • 2015-03-05
    • 2014-08-25
    • 2016-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多