简体   繁体   English

ICS(iCal)发布/请求/取消

[英]ICS (iCal) PUBLISH/REQUEST/CANCEL

I'm having a lot of trouble getting entries in a .ics file generated from PHP to update. 在从PHP生成的.ics文件中获取条目进行更新时,我遇到很多麻烦。 Here's an example of what I'm using: 这是我正在使用的示例:

<?php
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=calendar.ics');

$time = time();
$dtstamp = date('Ymd', $time). 'T' . date('His', $time) . 'Z'; echo "\r\n";
?>
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//My Event
METHOD:PUBLISH
X-WR-CALNAME:MyCal
BEGIN:VEVENT
DTSTAMP:<?php echo $dtstamp; ?>
ORGANIZER:someone@example.com
SEQUENCE:0
UID:ABC123
DTSTART:20150601T120000
DTEND:20150601T130000
SUMMARY:Event 1 - <?php echo date('His', $time) ."\r\n"; ?>
LOCATION:Location 1
DESCRIPTION:This is Event 1 - <?php echo date('His', $time) ."\r\n"; ?>
END:VEVENT
BEGIN:VEVENT
DTSTAMP:<?php echo $dtstamp; ?>
ORGANIZER:someone@example.com
SEQUENCE:0
UID:DEF123
DTSTART:20150601T160000
DTEND:20150601T170000
SUMMARY:Event 2 - <?php echo date('His', $time) ."\r\n"; ?>
LOCATION:Location 2
DESCRIPTION:This is Event 2 - <?php echo date('His', $time) ."\r\n"; ?>
END:VEVENT
END:VCALENDAR

So this is to output the events to a URL that can be hit in an Android or iOS device and added to the calendar. 因此,这是将事件输出到可以在Android或iOS设备中点击并添加到日历的URL。 The next step would be to update the event items when needed. 下一步将是在需要时更新事件项。 I've been trying to do it with something like this (initial PHP deliberately omitted): 我一直在尝试使用类似的方法(故意省略了初始PHP):

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//My Event
METHOD:PUBLISH
X-WR-CALNAME:MyCal
BEGIN:VEVENT
DTSTAMP:<?php echo $dtstamp; ?>
ORGANIZER:someone@example.com
SEQUENCE:1
UID:ABC123
DTSTART:20150601T123000
DTEND:20150601T130000
SUMMARY:Event 1 - <?php echo date('His', $time) ."\r\n"; ?>
LOCATION:Location 1
DESCRIPTION:This is Event 1 - <?php echo date('His', $time) ."\r\n"; ?>
END:VEVENT
BEGIN:VEVENT
DTSTAMP:<?php echo $dtstamp; ?>
ORGANIZER:someone@example.com
SEQUENCE:1
UID:DEF123
DTSTART:20150601T163000
DTEND:20150601T170000
SUMMARY:Event 2 - <?php echo date('His', $time) ."\r\n"; ?>
LOCATION:Location 2
DESCRIPTION:This is Event 2 - <?php echo date('His', $time) ."\r\n"; ?>
END:VEVENT
END:VCALENDAR

Because the DTSTAMP will always be greater than the previous entry, the sequence has been incremented and the METHOD changed to REQUEST, as far as I can tell that should be enough. 因为DTSTAMP将始终大于上一个条目,所以据我所知,该序列已增加,并且Method更改为REQUEST。

However in Android it just adds the events again, in iOS it displays the events that already exist, with the previous details, and only gives you the option to add the events again. 但是,在Android中,它只是再次添加事件,在iOS中,它会显示已经存在的事件以及以前的详细信息,并且只提供重新添加事件的选项。 So, I'm wondering what it takes to get the existing events to update, and to later cancel them using METHOD:CANCEL if need be. 因此,我想知道如何更新现有事件,并在以后需要时使用METHOD:CANCEL取消它们。

Thanks. 谢谢。

What you are trying to do is not possible. 您试图做的事是不可能的。

What you probably should be doing, is to create an iCalendar feed. 您可能应该做的是创建一个iCalendar供稿。 (Usually the webcal:// non-standard URI schema is used for this). (通常使用webcal://非标准URI模式进行此操作)。

A feed like this should only ever have METHOD:PUBLISH and always contain every single item in the calendar . 这样的供稿应仅具有METHOD:PUBLISH并且始终包含日历中的每个项目

To update entries in this feed, you will need to simply update the feed itself. 要更新此供稿中的条目,您只需简单地更新供稿本身。 Any items you remove in this feed, are removed from the calendar. 您在此Feed中删除的所有项目都会从日历中删除。

METHOD:CANCEL and METHOD:REQUEST are other iTip methods that are not used in this context. METHOD:CANCELMETHOD:REQUEST是在此上下文中未使用的其他iTip方法。 There's two major uses for them: 它们有两个主要用途:

  1. Email invites (aka iMip). 电子邮件邀请(又名iMip)。
  2. CalDAV scheduling CalDAV排程

Those methods only really have meaning for iCalendar events that have an ORGANIZER and ATTENDEE s 这些方法仅对具有ORGANIZERATTENDEE的iCalendar事件真正有意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM