【问题标题】:Link to add to Google calendar添加到 Google 日历的链接
【发布时间】:2012-05-16 08:37:26
【问题描述】:

我不清楚在将单个事件添加到用户 Google 日历的网站上具有链接的确切格式。我看到 eventbrite 已经在这里完成了,但我希望有一些明确的规格或正确方向的链接

http://www.eventbrite.com/event/1289487893

http://screencast.com/t/6vvh1khS

【问题讨论】:

标签: google-calendar-api


【解决方案1】:

这是一个示例链接,您可以使用它来查看格式:

https://www.google.com/calendar/render?action=TEMPLATE&text=Your+Event+Name&dates=20140127T224000Z/20140320T221500Z&details=For+details,+link+here:+http://www.example.com&location=Waldorf+Astoria,+301+Park+Ave+,+New+York,+NY+10022&sf=true&output=xml

注意关键查询参数:

text
dates
details
location

这是另一个例子(取自http://wordpress.org/support/topic/direct-link-to-add-specific-google-calendar-event):

<a href="http://www.google.com/calendar/render?
action=TEMPLATE
&text=[event-title]
&dates=[start-custom format='Ymd\\THi00\\Z']/[end-custom format='Ymd\\THi00\\Z']
&details=[description]
&location=[location]
&trp=false
&sprop=
&sprop=name:"
target="_blank" rel="nofollow">Add to my calendar</a>

如果您愿意,这里有一个表格可以帮助您构建这样的链接(在前面的答案中提到):

https://support.google.com/calendar/answer/3033039 编辑:此链接不再为您提供可以使用的表单

【讨论】:

  • 请注意,您还可以指定时区参数,例如:ctz=America/New_York
  • 转换为日期时间格式:(new Date()).toISOString().replace(/-|:|\.\d\d\d/g,"");
  • 上面的链接适用于桌面。对于移动类似的 url 是 calendar.google.com/calendar/gp#~calendar:view=e&bm=1 和参数是相同的。
  • 您可以在List of tz database time zones找到完整的CTZ值列表
  • @IvánSánchez 迟到的回复,但是,“日期”参数末尾的“Z”将设置 UTC 中的等效时间 - 因此您的时区可能是错误的。在每个日期的末尾删除“Z”,您会发现时间显示在正确的区域中。 dates=20140127T224000/20140320T221500
【解决方案2】:

有一个关于谷歌日历和其他日历服务的综合文档:https://github.com/InteractionDesignFoundation/add-event-to-calendar-docs/blob/master/services/google.md

工作链接示例:https://calendar.google.com/calendar/render?action=TEMPLATE&amp;text=Bithday&amp;dates=20201231T193000Z/20201231T223000Z&amp;details=With%20clowns%20and%20stuff&amp;location=North%20Pole

【讨论】:

    【解决方案3】:

    我也成功地使用了这个 URL 结构:

    基本网址:

    https://calendar.google.com/calendar/r/eventedit?
    

    假设这是我的活动详情:

    Title: Event Title
    Description: Example of some description. See more at https://stackoverflow.com/questions/10488831/link-to-add-to-google-calendar
    Location: 123 Some Place
    Date: February 22, 2020
    Start Time: 10:00am
    End Time: 11:30am
    Timezone: America/New York (GMT -5)
    

    我会将我的详细信息转换为这些参数(URL 编码):

    text=Event%20Title
    details=Example%20of%20some%20description.%20See%20more%20at%20https%3A%2F%2Fstackoverflow.com%2Fquestions%2F10488831%2Flink-to-add-to-google-calendar
    location=123%20Some%20Place%2C%20City
    dates=20200222T100000/20200222T113000
    ctz=America%2FNew_York
    

    示例链接:

    https://calendar.google.com/calendar/r/eventedit?text=Event%20Title&details=Example%20of%20some%20description.%20See%20more%20at%20https%3A%2F%2Fstackoverflow.com%2Fquestions%2F10488831%2Flink-to-add-to-google-calendar&location=123%20Some%20Place%2C%20City&dates=20200222T100000/20200222T113000&ctz=America%2FNew_York

    请注意,由于我使用“ctz”参数指定了时区,因此我使用本地时间作为开始和结束日期。或者,您可以使用 UTC 日期并排除时区参数,如下所示:

    dates=20200222T150000Z/20200222T163000Z
    

    示例链接:

    https://calendar.google.com/calendar/r/eventedit?text=Event%20Title&details=Example%20of%20some%20description.%20See%20more%20at%20https%3A%2F%2Fstackoverflow.com%2Fquestions%2F10488831%2Flink-to-add-to-google-calendar&location=123%20Some%20Place%2C%20City&dates=20200222T150000Z/20200222T163000Z

    【讨论】:

      【解决方案4】:

      对于下一个搜索此主题的人,我编写了一个小型 NPM 包,以简化生成 Google 日历 URL 的过程。它包括 TypeScript 类型定义,供需要的人使用。希望对您有所帮助!

      https://www.npmjs.com/package/google-calendar-url

      【讨论】:

        猜你喜欢
        • 2014-03-31
        • 2016-09-17
        • 1970-01-01
        • 2018-02-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多