您需要结合使用webcal
链接以及动态创建的 ics 文件。的用法webcal
如下:
<a href="webcal://createCal.php?title=Title&start=timestamp&end=timestamp&description=Arbitrary%20description%20text">Link</a>
但是,为了获得最佳兼容性,我认为您最好的选择是直接链接到该ics
文件:
<a href="createCal.php?title=Title&start=timestamp&end=timestamp&description=Arbitrary%20description%20text">Link</a>
然后,在该createCal.php
文件(或您选择的任何一种编程语言)中,您可以执行与本文类似的操作来动态创建一个ics
文件,用户可以将其导入到他们选择的日历程序中。
这是我为 PHP 文件的内容找到的另一个示例(请注意,这未经测试,但更多的是一个起点):
<?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";
?>