链接添加到Google日历


115

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

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

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


1
另请参阅以下问题和答案:stackoverflow.com/q/22757908
DenilsonSáMaia

1
在下面的注释中,参考如何将日期转换为所需格式的信息:stackoverflow.com/questions/10488831/…(花了一段时间让我注意到注释)
Elijah Lofgren

Answers:


231

这是您可以用来查看格式的示例链接:

https://www.google.com/calendar/render?action=TEMPLATE&text=Your+Event+Name&dates=20140127T224000Z/20140320T221500Z&details=详细信息,+ link +此处:+ 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 修改:此链接不再为您提供可使用的表格


29
请注意,您还可以指定时区参数,例如:ctz=America/New_York
用户

23
转换为日期时间格式:(new Date()).toISOString().replace(/-|:|\.\d\d\d/g,"");
Trantor Liu 2014年

7
上面的链接适用于台式机。对于移动设备,类似的网址为calendar.google.com/calendar/gp#~calendar:view=e&bm=1,并且参数相同。
Supreet Sethi


6
@IvánSánchez的回复很晚,但是,“ dates”参数末尾的“ Z”将设置UTC的等效时间-因此您所在的时区可能是错误的。在每个日期的末尾添加“ Z”,您会在正确的区域中找到显示的时间。dates=20140127T224000/20140320T221500
贾维斯·约翰逊


5

这个网址结构也很成功:

基本网址:

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

假设这是我的活动详细信息:

Title: Event Title
Description: Example of some description. See more at /programming/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日期并排除timezone参数,如下所示:

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


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.