在 PHP 中使用 MySQL 数据库创建动态 iCal
我正在尝试根据当前正在查看的事件为数据库中的每个事件创建一个动态 iCal 文件,但由于某种原因它不起作用。有什么想法吗?
$current_event = $db->GetRow(false, "SELECT * FROM event WHERE eventid = ".$_GET['eventid']);
$sql = "SELECT * FROM event WHERE eventid = '". $current_event['eventid'] ."'";
$data = $db->Query($sql);
$regdata = $db->GetRow($data);
$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20101231T230000
DTEND:20110101T01000
SUMMARY:TOO
LOCATION:Downtown
DESCRIPTION:".$current_event['eventid']."
SEQUENCE:0
DTSTAMP:20101125T112600
END:VEVENT
END:VCALENDAR
";
header("Content-Type: text/calendar;");
header("Content-Disposition: inline; filename=eventtooutlook.ics");
echo $ical;
exit;
I am trying to create a dynamic iCal file for each event in my database depending on which event is currently being looked at, but for some reason it's not working. Any ideas?
$current_event = $db->GetRow(false, "SELECT * FROM event WHERE eventid = ".$_GET['eventid']);
$sql = "SELECT * FROM event WHERE eventid = '". $current_event['eventid'] ."'";
$data = $db->Query($sql);
$regdata = $db->GetRow($data);
$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20101231T230000
DTEND:20110101T01000
SUMMARY:TOO
LOCATION:Downtown
DESCRIPTION:".$current_event['eventid']."
SEQUENCE:0
DTSTAMP:20101125T112600
END:VEVENT
END:VCALENDAR
";
header("Content-Type: text/calendar;");
header("Content-Disposition: inline; filename=eventtooutlook.ics");
echo $ical;
exit;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还尝试输出第一个
标头(“HTTP/1.0 200 OK”);
我遇到了一个奇怪的问题,我的代码在本地服务器上没问题,但在远程服务器上要么得到 404 要么 500,具体取决于我做了什么,直到我从
header('OK', true, 200) 更改为上面的代码。
原因可能是由于 php 版本 - 无论如何你没有状态标头,所以也许就是这样?
(旁白:你的 DTEND 也缺少 0 )
Also try outputting first
header("HTTP/1.0 200 OK");
I had a weird problem where my code was fine on local server, but then on remote server either got a 404 or 500 depending what I did, until i changed from
header('OK', true, 200) to the above code.
Cause maybe due to Versions of php - anyway you don't have a status header so maybe that is it?
(aside: also your DTEND is missing a 0 )