简体   繁体   English

使用php更新单个ics文件(icalendar流)中的多个事件

[英]Update of multiple events in a single ics file(icalendar stream) using php

After adding multiple events in a single ics file, I have used the given code for updating multiple events in a single ics file. 在单个ics文件中添加多个事件后,我使用了给定的代码来更新单个ics文件中的多个事件。 But its not working. 但是它不起作用。 The events are not updated. 事件未更新。 Any body please help me. 任何人请帮助我。 My code is given: 我的代码给出:

$ical = "BEGIN:VCALENDAR";    
$ical .= "\nVERSION:2.0";    
$ical .= "\nPRODID:-//hacksw/handcal//NONSGML v1.0//EN";    
$ical .= "\nMETHOD:REQUEST";    
$ical .= "\nCALSCALE:GREGORIAN";    
$ical .= "\nX-WR-RELCALID:asjh675adashdh";    
$ical .= "\nX-WR-CALNAME:My Nov Calendar";   

foreach($arr as $newArr){
    $ical .= "\nBEGIN:VEVENT";    
    $ical .= "\nUID:" . md5($newArr['stDate']) . "example.com";    
    $ical .= "\nSEQUENCE:1";    
    $ical .= "\nDTSTAMP:" . gmdate('Ymd');    
    $ical .= "\nORGANIZER:catalog@example.com";    
    $ical .= "\nDTSTART:".$newArr['stDate'];    
    $ical .= "\nDTEND:".$newArr['stDate'];    
    $ical .= "\nSUMMARY:".$newArr['sub'];    
    $ical .= "\nDESCRIPTION:".$newArr['desc'];    
    $ical .= "\nCLASS:PUBLIC";    
    $ical .= "\nSTATUS:CONFIRMED";    
    $ical .= "\nTRANSP:TRANSPARENT";    
    $ical .= "\nEND:VEVENT";    
}

$ical .= "\nEND:VCALENDAR";    
header('Content-type: text/calendar; charset=utf-8');    
header('Content-Disposition: inline; filename=my-calendar.ics');    
echo $ical;    
exit;

I have also change the SEQUENCE number but its not working. 我也更改了SEQUENCE编号,但它不起作用。

What property does change in each event ? 每个事件会改变什么属性?

Your UID property is based on the DTSTART of each event. 您的UID属性基于每个事件的DTSTART。 So if you change the start of the event, the UID changes. 因此,如果您更改事件的开始,则UID会更改。 UIDs must not change when updating an event. 更新事件时,UID不得更改。 It is the one thing that should remain constant for the whole lifecycle of the event. 在事件的整个生命周期中应保持不变的一件事。

Dont know what gmdate('Ymd') does exactly but DTSTAMP are supposed to be YYYYMMDDTHHMMSSZ format. 不知道gmdate('Ymd')到底能做什么,但是DTSTAMP应该是YYYYMMDDTHHMMSSZ格式。

Then you are missing a METHOD=REQUEST parameter in the content-type header but I dont think that is causing the failure to update. 然后,您在内容类型标头中丢失了METHOD = REQUEST参数,但我认为这不会导致更新失败。

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

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