wvrzel/simpleCalDAV

Get event data with line-breaks

Closed this issue · 3 comments

I need to have the data from getEvents() with line-breaks, so other libraries like https://github.com/u01jmg3/ics-parser can parse it.

How can this be achieved?

I found it out. Comment this line:

CalDAVClient->ParseResponse():
//xml_parser_set_option ( $parser, XML_OPTION_SKIP_WHITE, 1 );

And then the response will contain line-breaks.

Hello @doonot - Unfortunately this solution didn't work for me - when I pass getData to ICal (ics-parser) I only get the data in a string. When I echo getData and use the output for ICal it works as intended. Did you do anything further so ICal can parse the getData-output?

getData does output line-breaks - ICal just does not accept them and I can't tell why.

array(1) { [""]=> array(1) { ["BEGIN"]=> string(938) "VCALENDARVERSION:2.0PRODID:-//DDay.iCal 1.0//ENBEGIN:VTIMEZONETZID:W. Europe Standard TimeBEGIN:STANDARDDTSTART:19701025T030000RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=3;BYMINUTE=0;BYMONTH=10TZNAME:Mitteleuropäische ZeitTZOFFSETFROM:+0200TZOFFSETTO:+0100END:STANDARDBEGIN:DAYLIGHTDTSTART:19700329T020000RRULE:FREQ=YEARLY;BYDAY=-1SU;BYHOUR=2;BYMINUTE=0;BYMONTH=3TZNAME:Mitteleuropäische SommerzeitTZOFFSETFROM:+0100TZOFFSETTO:+0200END:DAYLIGHTEND:VTIMEZONEBEGIN:VEVENTCLASS:PUBLICDESCRIPTION:Auch in Frankfurt kann man sich bilden.DTEND;TZID=W. Europe Standard Time:20170720T153000DTSTAMP:20170709T182342ZDTSTART;TZID=W. Europe Standard Time:20170720T070000LOCATION:FrankfurtPRIORITY:5SEQUENCE:0SUMMARY:Bildung ist wichtigTRANSP:OPAQUEUID:f845c376-b444-4258-be40-e50393423b7aX-MICROSOFT-CDO-BUSYSTATUS:BUSYBEGIN:VALARMACTION:DISPLAYDESCRIPTION:This is an event reminderTRIGGER:-PT15MEND:VALARMEND:VEVENTEND:VCALENDAR" } }

After lots of trying I found another solution:

$content = $events[0]->getData(); $content = str_replace("\n", PHP_EOL, $content);
This made it possible for me to make ics-parser recognize the result and parse as an array.