php Icalendar源无效
我有一个生成ical提要的代码php Icalendar源无效,php,icalendar,Php,Icalendar,我有一个生成ical提要的代码 $ical = "BEGIN:VCALENDAR PRODID:-//Booking Hosting Calendar//EN VERSION:2.0"; $ical.=booking_ical_get_booking_dates($post_id); $ical.=" END:VCALENDAR"; header('Content-type: text/calendar; charset=utf-8'); header('Content-Disposition
$ical = "BEGIN:VCALENDAR
PRODID:-//Booking Hosting Calendar//EN
VERSION:2.0";
$ical.=booking_ical_get_booking_dates($post_id);
$ical.="
END:VCALENDAR";
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
print $ical;
exit;
当我尝试在icalendar.org上验证提要(通过url)时,我收到了这个错误消息
Lines not delimited by CRLF sequence near line # 1
如果我只是在同一个生成器中复制粘贴文件的内容,它将进行验证
我想这是我结束台词的方式,我尝试添加
echo "\r\n"
在每行之后或使用PHP\u EOL,但没有运气。有什么建议吗
更新
现在代码如下所示
$ical = "BEGIN:VCALENDAR\r\n";
$ical .="PRODID:-//Booking Hosting Calendar//EN\r\n";
$ical .="VERSION:2.0\r\n";
$ical.=booking_ical_get_booking_dates($post_id);
$ical.="END:VCALENDAR";
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
print $ical;
exit;
但我仍然收到相同的错误。您的预订日期函数必须缺少每行的CRLF。前两行还行,其余不行
还可以看到我的评论,重新折叠行-通常,如果人们没有正确的CRLF,他们通常也没有折叠长行。请参见为什么要使用PHP\u EOL?根据脚本运行的平台,特定用于导致换行符的不同“版本”的常量?如果需要,请使用\r\n。我编辑了该问题,因为并非所有内容都可见-我尝试在使用PHP\u EOL之前添加“\r\n”,但不起作用。您指定的值中的换行符取决于您保存文件的方式。我只需使用以下形式:
$ical=“foo\r\n”$ical.=“下一行\r\n”代码>-因此,每行追加一行,并在每行末尾包含适当的换行符。通过在多行上书写单个文本文字,不会出现“隐式”换行。谢谢您的回答。我这样做了(参见更新),但问题仍然存在。现在插入的变量值和下一行END:VCALENDAR
之间似乎缺少换行符。(那么,booking\u icial\u获得什么样的预订日期
return,是否包括必要的适当换行?)