在 PHP ical 上的任何 Google 搜索都会显示 phpicalendar 以及如何解析或读取 IN ical 文件.我只想编写一个 PHP 文件,从我的数据库中提取事件并以 ical 格式写出.
Any Google search on PHP ical just brings up phpicalendar and how to parse or read IN ical files. I just want to write a PHP file that pulls events from my database and writes them out in ical format.
我的问题是我找不到可以回答两个问题的地方:
My problem is I can't find anywhere that will answer two questions:
大家可以给予或指点我的任何帮助将不胜感激!!!
Any help you all can give or point me to will be greatly appreciated!!!
如果 Google Calendar 不需要 *.ics
-extension(这将需要在服务器).
This should be very simple if Google Calendar does not require the *.ics
-extension (which will require some URL rewriting in the server).
$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "@yourhost.test
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR";
//set correct content-type-header
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
echo $ical;
exit;
这基本上就是让客户认为您正在提供 iCalendar 文件所需的全部内容,即使在缓存、文本编码等方面可能存在一些问题.但是您可以开始尝试这个简单的代码.
That's essentially all you need to make a client think that you're serving a iCalendar file, even though there might be some issues regarding caching, text encoding and so on. But you can start experimenting with this simple code.
这篇关于如何使用 PHP 动态发布 ical 文件以供 Google 日历读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!