如何发布Google日历的动态事件供稿? [英] How to publish a dynamic event feed for google calendar?

查看:89
本文介绍了如何发布Google日历的动态事件供稿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Webapp,用于管理用户的某些类型的事件.我想提供一种在用户的Google日历中显示这些事件的方法.

I'm building a webapp that manages certain types of events for users. I want to provide a way to display those events inside of a user's google calendar.

我真正希望的是一种发布自己的Google日历兼容供稿并允许用户对其进行订阅的方法,就像他们可以订阅有趣的日历"一样.这样,如果事件发生更改或添加了新事件,则它们会反映在其日历中.但是看起来Google只允许用户以ical或csv格式导入日历数据,而不是原子供稿格式.

What I was really hoping for was a way to publish my own google calendar compatible feed and allow users to subscribe to it, like they can subscribe to "interesting calendars". So that if events change or new events are added, they are reflected in their calendar. But it looks like google only lets users import calendar data in ical or csv formats, not in atom feed format.

问题是,我的Web应用程序中的现有事件可以更改,并且添加了新事件.我希望这些更改能够立即反映在Google日历中.而且我不能指望用户继续重新导入ICAL文件.以下SO问题极为相似,但实际上并没有发布答案: 生成与Google日历兼容的供稿

The problem is, existing events in my webapp can change and new events are added. I want those changes to immediately be reflected in google calendar. And I can't expect a user to keep reimporting an ICAL file. The following SO question is extremely similar, but doesn't really have an answer posted: Generate a Google Calendar compatible feed

我会以错误的方式处理吗?我是否需要使用gdata API创建日历并向其中发布事件?似乎发布原子供稿要简单得多,但是如果Google无法订阅原子供稿,那将行不通.

Am I going about this the wrong way? Do I need to be using the gdata API to create a calendar and publish events to it? It seems like publishing an atom feed would be much simpler, but if google can't subscribe to an atom feed, that won't work.

如果我只是将事件发布为ICAL文件,那么Google日历会定期重新读取URL并更新数据吗?我的某些用户每天有4或5个事件,因此文件会随着时间的流逝而越来越大.看来这似乎不是一个很好的解决方案.

If I simply publish my events as an ICAL file, will google calendar reread the URL regularly and update the data? Some users my have 4 or 5 events each day, so the file will just keep getting bigger and bigger as time goes on. It really seems like this isn't a good solution.

推荐答案

再看看其他这样做的网站,看来google确实会定期重新阅读ical格式的外部日历.

Looking at other sites that do this, it would seem that google does re-read external calendars in ical format regularly.

然后由您决定是否要删除您提供的文件摘要,例如通过杀死过去的日期来

It then's up to you to trim the ical feed you provide e.g by killing dates in the past.

所以要解决您的问题:

  • 生成一个ical文件并从您的网站提供服务
  • 让您的用户在Google日历中订阅
  • 定期刷新ical文件,修剪旧数据

示例标头& TripIt.com上的ics文件的开头,在这里看来效果很好:

Example headers & start of ics file from TripIt.com, where this seems to work well:

curl -v http://..../tripit.ics

< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 29 Jan 2010 21:53:58 GMT
< Content-Type: text/calendar; charset=utf-8
< Transfer-Encoding: chunked
< Connection: close
< Expires: Fri, 29 Jan 2010 22:08:58 GMT
< Cache-Control: private
< 
BEGIN:VCALENDAR
X-WR-CALNAME:Malcolm Box (TripIt)
X-WR-CALDESC:TripIt Calendar
X-PUBLISHED-TTL:PT15M
PRODID:-//John Papaioannou/NONSGML Bennu 0.1//EN
VERSION:2.0
BEGIN:VEVENT
...

这篇关于如何发布Google日历的动态事件供稿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆