我在这家夜总会工作,目前正在为他们制作一个网站,他们有很多活动,他们的网站很多都是围绕活动构建的,今天他们为每个活动制作了一个 Facebook 活动,但如果有一个“添加到我的日历”按钮,将其添加到您的 iCal 或 Google 日历(甚至可能是 Outlook)。
我已经设法弄清楚如何制作日历提要,但随后它将作为新日历添加,唯一的好处是人们可以“订阅事件”,但为每个事件都有一个日历是相当混乱的。所以我想知道如何实现一个功能,让他们可以轻松地将其添加到他们的主日历中。像 mailto: 链接一样思考,但如果可能的话,用于日历。
另外,当我谈论这个主题时,有谁知道是否可以自动将事件从 Facebook 导入到 WordPress 或将事件从 WordPress 导出到 Facebook,这会很棒,但这并不那么重要。
I'm working for this nightclub and are currently making a website for them, they've got lots events and their site is built a lot around events, today they make an facebook event of every event but it would be killer to have a "Add to my Calendar" button which added it to your iCal or Google Calendar (or maybe even Outlook).
I've managed to figure out how to make an calendar feed but then it will be added as a new calendar, only good thing is that people can "subscribe to events" but it's quite messy to have an calendar for every event. So I would like to know how to implement a function which lets them add it to their main calendar easily. Think like a mailto: link but for calendars if that's possible.
Also while I'm on the subject, does anyone know if it's possible to automatically import an event from Facebook to WordPress or export an event from WordPress to Facebook that would be great, but that's not so important.
发布评论
评论(7)
戴夫帖子中的链接很棒。只是将有关谷歌链接的一些技术细节放入此处的答案中:
Google Calendar Link
添加到 gCal
参数为:
2018 年 2 月更新:
这是一个新的链接结构,似乎支持新的谷歌版本的谷歌日历 w /o 需要 API 交互:
https://calendar.google.com/calendar/r/eventedit?text=My+Custom+Event&dates=20180512T230000Z/20180513T030000Z&details=For+details,+link+此处: +https://example.com/tickets-43251101208&location=Garage+Boston+-+20+Linden+Street+-+Allston,+MA+02134
新基本网址:
https://calendar. google.com/calendar/r/eventedit
新参数:
注意:
%20
之外,更好地接受+
空间(urlencode
与rawurlencode
> 在 php 中 - 两者都有效)The links in Dave's post are great. Just to put a few technical details about the google links into an answer here on SO:
Google Calendar Link
<a href="http://www.google.com/calendar/event?action=TEMPLATE&text=Example%20Event&dates=20131124T010000Z/20131124T020000Z&details=Event%20Details%20Here&location=123%20Main%20St%2C%20Example%2C%20NY">Add to gCal</a>
the parameters being:
Update Feb 2018:
Here's a new link structure that seems to support the new google version of google calendar w/o requiring API interaction:
https://calendar.google.com/calendar/r/eventedit?text=My+Custom+Event&dates=20180512T230000Z/20180513T030000Z&details=For+details,+link+here:+https://example.com/tickets-43251101208&location=Garage+Boston+-+20+Linden+Street+-+Allston,+MA+02134
New base url:
https://calendar.google.com/calendar/r/eventedit
New parameters:
Notes:
+
for space in addition to%20
(urlencode
vsrawurlencode
in php - both work)更新(免费供个人使用):
现在支持 HTTPS
虽然我在下面的回答详细介绍了每个服务的操作方法,但在我看来,现在使用像 这样的第三方会更容易AddThisEvent [https://addthisevent.com]。它可以让您自定义许多选项以及添加到 Facebook 等。 不幸的是,他们现在已将其作为除个人使用之外的任何其他服务的付费服务,并且确实强制执行这一点。
我认为还有其他类似的第三方解决方案,但我只能谈论这个,到目前为止,它对我们来说效果很好。
对于“添加到我的 Google 日历”,他们曾经有一个可供您使用的代码生成器表单,但后来已将其删除。有关 Google 日历链接的更多详细信息,请参阅 squarecandy 的回答如下。
对于 Outlook,情况要复杂一些,但基本上您需要使用事件数据创建一个
.vcs
文件,然后创建指向该文件的链接。 步骤-此处的分步说明。对于 iCal 链接,您可以使用 PHP 类 喜欢这个,或关注 本页说明,介绍如何创建
ics
文件(iCal 文件)。UPDATE (free for personal use):
HTTPS IS NOW SUPPORTED
While my answer below detailing how-to for each service WILL work, IMO it's much easier now to go with a third-party like AddThisEvent [https://addthisevent.com]. It lets you customize lots of options as well as add to Facebook and more. Unfortunately, they've now made it a paid service for anything other than personal use and do enforce this.
I assume there are other third-party solutions like this one, but I can only speak to this one, and it has worked great for us so far.
For an "Add to my Google Calendar", they used to have a code generator form you could use, but have since taken it down. For more details on Google Calendar links, see squarecandy's answer below.
For Outlook, it's a BIT more complicated, but basically you need to create a
.vcs
file with the event's data, and just make a link to that file. Step-by-step instructions here.For an iCal link, you could use a PHP class like this one, or follow this page's instructions on how to create an
ics
file (iCal file).为了添加到 squarecandy 的 Google 日历贡献中,这里使用全新的
OUTLOOK CALENDAR 格式(无需创建 .ics)!
测试一下
最好对摘要、位置和描述变量的值进行 url_encode。< /em>
为了了解知识,
YAHOO CALENDAR 格式
测试一下
在没有第三方的情况下进行测试有很多优点,例如在电子邮件中使用它。
To add to squarecandy's google calendar contribution, here the brand new
OUTLOOK CALENDAR format (Without a need to create .ics) !!
test it
Best would be to url_encode the summary, location and description variable's values.
For the sake of knowledge,
YAHOO CALENDAR format
test it
Doing it without a third party holds a lot of advantages for example using it in emails.
Litmus 有一篇很棒的文章,详细介绍了如何构建一个在主要电子邮件和日历客户端上运行良好的简洁解决方案,包括为使用不同供应商的客户端的用户提供服务。
考虑到这个空间的非标准化性质,这绝非小事,但如果您愿意卷起袖子几天,您可以获得一些效果很好且不需要每月价格标签的东西以及使用限制!
https:// /www.litmus.com/blog/how-to-create-an-add-to-calendar-link-for-your-emails/
Litmus has a great post detailing how to build a neat solution that works well across the major email and calendar clients, including catering for users who use clients from different vendors.
It is far from trivial, given the non-standardised nature of this space, but if you're willing to roll up your sleeves for a couple of days, you can get something that works well and doesn't come with a monthly price tag and limits on usage!
https://www.litmus.com/blog/how-to-create-an-add-to-calendar-link-for-your-emails/
您可以生成一个 ics 文件,其中包含会议信息
ics 文件看起来像这样,
生成 ics 文件的 java 代码也在这里
You can generate a ics file which include the meeting information
the ics file look like this
also the java code to generate ics file is here
简单&免费解决方案
使用add-to-calendar-button.com。
请参阅 现场演示
给定的代码将生成一个按钮,用于在日历中添加上午 8 点到 10 点的事件2024 年 4 月 9 日。
此外,我还构建了一个 JS 函数来通过函数调用添加详细信息:
如需更多自定义,请访问 此处。
Simple & Free solution
Using CDN library provided by add-to-calendar-button.com.
See Live Demo
Given code will generate a button to add an event in calendar from 8 to 10am on 9th April 2024.
Additionally, I have built a JS function to add the details through a function call:
For more customizations, visit here.
您可以让程序创建日历的 .ics (iCal) 版本,然后您可以将此 .ics 导入到您想要的任何日历程序中:Google、Outlook 等。
我知道这篇文章很旧,所以我赢了不用费心输入任何代码。但如果您希望我提供如何执行此操作的概述,请对此发表评论。
You can have the program create an .ics (iCal) version of the calendar and then you can import this .ics into whichever calendar program you'd like: Google, Outlook, etc.
I know this post is quite old, so I won't bother inputting any code. But please comment on this if you'd like me to provide an outline of how to do this.