5

有没有办法创建一个通用链接来创建一个日历事件作为 HTML 锚的 URI?例如,您可以创建一个使用 来创建电子邮件的链接<a href="mailto:address@example.com?Subject=Subject%20line&body=Body%20content.">Link text</a>,并且您可以创建一个使用 发起电话呼叫的链接<a href="callto:5551234567">Link text</a>对于不是程序特定的日历,是否有这样的语法?(我知道有些东西outlook://,iCal 可以使用.ics文件,但我想要一个与程序无关的东西)

我正在寻找类似的东西<a href="cal:Event%20title?start=timestamp&end=timestamp&description=Arbitrary%20description%20text>Link text</a>

4

1 回答 1

5

您需要结合使用webcal链接以及动态创建的 ics 文件。的用法webcal如下:

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

但是,为了获得最佳兼容性,我认为您最好的选择是直接链接到该ics文件:

<a href="createCal.php?title=Title&amp;start=timestamp&amp;end=timestamp&amp;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";
?>
于 2012-11-28T15:44:11.017 回答