3

Well, I created a litle script to generate iCal events and automatically add it to the calendar using the webcal protocol.

The script worked as follows: I host the ical-generator.php file on the server and send a url with the necessary information by adding the webcal at the beginning.

webcal://www.test.com/ical-generator.php?id=66038&titulo=Teste&data-inicio=20190311&data-final=20190312&local=Teste&descricao=Lorem Ipsum dolor&url=http://www.test.com/

However, when I import the event into the calendar, this event, which is unique, ends up being added as a new calendar and not as a single event, which should be added to the user's existing calendar.

Here's the script:

    <?php
header("Content-type: text/calendar; charset=utf-8");
header("Content-Disposition: inline; filename=\"teste-evento-".$_GET['titulo'].".ics" ."\"");

echo "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//TESTE//NONSGML Teste//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VEVENT
UID:".$_GET['id']."-teste.com.br
ORGANIZER;CN=TESTE:MAILTO:teste@teste.com.br
SUMMARY:".$_GET['titulo']."
STATUS:CONFIRMED
DTSTART:".$_GET['data-inicio']."
DTEND:".$_GET['data-final']."
DTSTAMP:".date('Ymd').'T'.date('His')."
LOCATION:".$_GET['local']."
DESCRIPTION:".$_GET['descricao'].".\nSaiba mais em: ".$_GET['url']."
URL:".$_GET['url']."
CLASS:PUBLIC
TRANSP:TRANSPARENT
PRIORITY:5
SEQUENCE:0
X-MICROSOFT-CDO-IMPORTANCE:1
END:VEVENT
END:VCALENDAR";

1 Answers1

0

( Please note that webcal is unofficial URI (fairly well supported it is true however the Official uri is http/s and should be supported by all calendar applications. See https://www.rfc-editor.org/rfc/rfc5545#section-3.8.4.6 and https://en.wikipedia.org/wiki/Webcal. )

Now how an application treats an ics file or URL usually depends on what the user does. EG: in Google calendar, if one clicks add calendar > import, google will offer a default of your main calendar to import into, or allow one to select from one's other calendars.

IF however one clicks add calendar -> from URL, then google calendar will 'subscribe' - ie create a new calendar under 'other calendars' (to which one cannot 'import' futher events)

If attached to an email, most applications will expect one event only and will prompt one to add to one's default calendar.

Double Check what you did in testing and please ensure that you use a UNIQUE UID for each event to ensure that the application retests as though it were a new event (or delete the previous event). Some are clever enough to say 'hey this is the same event' and it makes testing confusing.

Community
  • 1
  • 1
anmari
  • 3,830
  • 1
  • 15
  • 15