1
votes

I'm trying to synchronize PHP-written calendar with Kerio Connect calendar(iCal). I have no problems with connecting to calendar and fetching events. But when I try to PUT any new event it seems that empty event is added, for example:

my request:

HEADERS: PUT /calendars/localhost/marcin/Calendar HTTP/1.1 Authorization: Basic bWFyY2luOnJob21hbg== Host: localhost:1212 If-None-Match: * Content-type: text/icalendar Content-Length: 367

REQEST: BEGIN:VCALENDAR PRODID:-//Kerio Technologies//Kerio Connect//EN METHOD:PUBLISH VERSION:2.0 X-VERSION-KMS:6.2.0 BEGIN:VEVENT DTSTART;VALUE=DATE:20120528T163000 DTEND;VALUE=DATE:20120528T170000 SEQUENCE:0 SUMMARY:test event CLASS:PUBLIC PRIORITY:5 TRANSP:OPAQUE X-MICROSOFT-CDO-BUSYSTATUS:BUSY X-LABEL:0 END:VEVENT END:VCALENDAR

RESPONSE: HTTP/1.1 201 Created Allow: OPTIONS, TRACE, GET, HEAD, DELETE, PUT, COPY, MOVE, PROPFIND, PROPPATCH, SEARCH, SUBSCRIBE, UNSUBSCRIBE, POLL, BDELETE, BCOPY, BMOVE, BPROPPATCH, BPROPFIND, LOCK, UNLOCK Connection: Close Content-Length: 0 Content-Type: text/html Date: Sun, 27 May 2012 13:33:04 GMT ETag: 1f353abd967f4700b8dc18f4d4775ff30000003400000001 Location: /calendars/localhost/marcin/Calendar/ Repl-UID: ResourceTag:

doesn't matter what dates/subject I put in request, created event always looks like this: Subject: Date: Sun, 27 May 2012 15:33:04 +0200 Content-Type: text/calendar; component="vevent"; method="PUBLISH"; charset="utf-8" Content-Transfer-Encoding: 8bit

BEGIN:VCALENDAR PRODID:-//Kerio Technologies//Kerio Connect//EN METHOD:PUBLISH VERSION:2.0 X-VERSION-KMS:6.2.0 BEGIN:VEVENT DTSTAMP:20120527T133304Z UID:10a69ad8-07f1-4831-a015-4de3dac78351 TRANSP:OPAQUE X-MICROSOFT-CDO-BUSYSTATUS:BUSY END:VEVENT END:VCALENDAR

So there is no subject, and no dates (DTSTART,DTEND); I've tried to send empty request: BEGIN:VCALENDAR BEGIN:VEVENT END:VEVENT END:VCALENDAR

and the result was the same.

I'm new to calDAV and I'm trying to solve this for last few days. If someone could help me and tell me what am I doing wrong, it would be awesome.

Best Regards Martin

1

1 Answers

1
votes

I too am had the exact issue. I push the event but kerio shows no subject or dates. Here is what I found to work (I could only get curl to work, no luck with fsockopen):

$uid = "test-12345"; // setting this to an existing uid updates event, a new uid adds event
$url = $account['uri'].'/'.$uid.'.ics'; //http://mail.domain.com/calendars/DOMAIN/USER/Calendar/'.$uid.'.ics'
$userpwd = $account['user'] .":". $account['pass'];
$description = 'My event description here';
$summary = 'My event title 1';
$tstart = '201206015T000000Z';
$tend = '20120616T000000Z';
$tstamp = gmdate("Ymd\THis\Z");

$body = <<<__EOD
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:$tstamp
DTSTART:$tstart
DTEND:$tend
UID:$uid
DESCRIPTION:$description
LOCATION:Office
SUMMARY:$summary
END:VEVENT
END:VCALENDAR
__EOD;

$headers = array(
    'Content-Type: text/calendar; charset=utf-8',
    'If-None-Match: *',
    'Expect: ',
    'Content-Length: '.strlen($body),
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_exec($ch);
curl_close($ch);