【问题标题】:Google Calendar - Get shareable link via API / get 'cid' value for a calendarGoogle 日历 - 通过 API 获取可共享链接/获取日历的“cid”值
【发布时间】:2019-08-04 14:51:30
【问题描述】:

我可以通过 API 获取 Google 日历的“cid”值吗?

Google Calendar Service API list/insert 函数中返回的“id”不是很有用(与使用 Google Drive 服务时“id”的用处不同)。使用返回的“id”,我可以构建公共日历的 URL,但我真正想做的是构建 URL 以将日历添加到您的日历中。与您转到日历设置并单击“获取可共享链接”时所做的相同。

共享链接如下所示:

https://calendar.google.com/calendar?cid=reallyLongSequenceOfLettersAndNumber

如果我可以通过编程方式获得“cid”值...

以下是使用 API 列出日历时返回的数据:

【问题讨论】:

    标签: calendar google-calendar-api


    【解决方案1】:

    我找到了答案here

    原来返回的“id”是base64编码的“cid”。显然有时原来的 'id' 会作为 'cid'.. 参考上面的链接了解更多信息。

    我将“id”转换为base64的python函数如下:

        def getCalenderCID(calendarId):
            calendarId_bytes = calendarId.encode('utf-8')
            cid_base64 = base64.b64encode(calendarId_bytes)
            cid = cid_base64.decode().rstrip('=')
            return cid
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多