Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Anchor to calendar?

Tags:

html

uri

anchor

Is there a way to make a generic link to create a calendar event as an HTML anchor's URI? For instance, you can make a link that creates an email with <a href="mailto:[email protected]?Subject=Subject%20line&body=Body%20content.">Link text</a>, and you can make a link that initiates a phone call with <a href="callto:5551234567">Link text</a>. Is there such a syntax for calendars that is NOT program specific? (I know there are things like outlook:// and iCal can use .ics files, but I want a program-agnostic one)

I'm looking for something like <a href="cal:Event%20title?start=timestamp&end=timestamp&description=Arbitrary%20description%20text>Link text</a>

like image 574
Ky. Avatar asked Oct 05 '22 20:10

Ky.


1 Answers

You'll need to use a combination of the webcal link as well as a dynamically created ics file. Usage of webcal would be as follows:

<a href="webcal://createCal.php?title=Title&amp;start=timestamp&amp;end=timestamp&amp;description=Arbitrary%20description%20text">Link</a>

However, for best compatibility, I think your best bet would be to just link directly to the ics file:

<a href="createCal.php?title=Title&amp;start=timestamp&amp;end=timestamp&amp;description=Arbitrary%20description%20text">Link</a>

Then, in the createCal.php file (or whichever your programming language of choice is) you could do something similar to this article to create an ics file on the fly that the user could import into their calendar program of choice.

Here's another sample I found for the contents of the PHP file (note that this isn't tested, but more so a starting point):

<?php
//Set the content-type of the file
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=Calendar.ics");
echo "BEGIN:VCALENDAR\n";
echo "PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\n";
echo "VERSION:2.0\n";
echo "METHOD:PUBLISH\n";
echo "X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n";
echo "BEGIN:VEVENT\n";
echo "CLASS:PUBLIC\n";
echo "CREATED:".date('Ymd\THis', time())."\n";
echo "DESCRIPTION:".$_GET['description'];
echo "DTEND:".date('Ymd\THis', $_GET['end'])."\n";
echo "DTSTAMP:".date('Ymd\THis', time())."\n";
echo "DTSTART:".date('Ymd\THis', $_GET['start'])."\n";
echo "LAST-MODIFIED:".date('Ymd\THis', time())."\n";
echo "LOCATION:\n";
echo "PRIORITY:5\n";
echo "SEQUENCE:0\n";
echo "SUMMARY;LANGUAGE=en-us:".$_GET['title']."\n";
echo "TRANSP:OPAQUE\n";
echo "UID:040000008200E00074C5B7101A82E008000000008062306C6261CA01000000000000000\n";
echo "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n";
echo "X-MICROSOFT-CDO-IMPORTANCE:1\n";
echo "X-MICROSOFT-DISALLOW-COUNTER:FALSE\n";
echo "X-MS-OLK-ALLOWEXTERNCHECK:TRUE\n";
echo "X-MS-OLK-AUTOFILLLOCATION:FALSE\n";
echo "X-MS-OLK-CONFTYPE:0\n";
//Here is to set the reminder for the event.
echo "BEGIN:VALARM\n";
echo "TRIGGER:-PT1440M\n";
echo "ACTION:DISPLAY\n";
echo "DESCRIPTION:Reminder\n";
echo "END:VALARM\n";
echo "END:VEVENT\n";
echo "END:VCALENDAR\n";
?>
like image 81
jmgardn2 Avatar answered Oct 13 '22 10:10

jmgardn2