好吧,一直围着这个圈子,尝试在新线上获取内容或折叠。我已经尝试了两个验证器,可以得到这个有效但它给我行长警告 - https://icalendar.org/validator.html
我不知道如何输入CRLF,如spec - https://tools.ietf.org/html/rfc2445#section-4.1中所述
这个验证器告诉我\ n已经过时但是当我更改为\ r \ n时,它会使我的描述无效。 - http://severinghaus.org/projects/icv/
我试过了
我试过$ description = str_replace(“\ r \ n”,'\ n',$ htmlMsg); $ description = str_replace(“ “,'\ n',$ description); $ description =(str_replace(”;“,”\;“,str_replace(”,“,”\,',$ description)));
与...结合
我试过了
$htmlMsg = "Adding event to your schedule does not confirm your reservation.\nVisit http://www.website.com for attendance details."
$temp = str_replace(array("\r\n"),"\n",$htmlMsg);
$lines = explode("\n",$temp);
$new_lines =array();
foreach($lines as $i => $line)
{
if(!empty($line))
$new_lines[]=trim($line);
}
$desc = implode("\r\n ",$new_lines);
php目前:
$output = "BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//App, Inc.//Calendar//EN
X-WR-TIMEZONE:America/Los_Angeles
CALSCALE:GREGORIAN\r\n";
foreach ($events as $event):
$numb = $numb+1;$output .=
"BEGIN:VEVENT
ORGANIZER;CN=BB:MAILTO:email@gmail.com
DTSTAMP:" . date(dateToCal) . "
SUMMARY:" . $event['te']['title'] . "
UID:" . $numb . $event['te']['id'] . "
DTSTART:" . gmdate(DATE_ICAL, strtotime($event['te']['sdate'])) . "
DTEND:" . gmdate(DATE_ICAL, strtotime($event['te']['edate'])) . "
DESCRIPTION:" . $desc . "
X-ALT-DESC;FMTTYPE=text/html:" . $desc . "
LOCATION:" . $event['te']['location'] . "
END:VEVENT\r\n";
endforeach;
// close calendar
$output .= "END:VCALENDAR";
除了新行问题,我还想在说明中添加一个链接。希望解决方案在Apple Calendar,Google和Outlook中有效并正常运行。
ics输出
BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//App, Inc.//Calendar//EN
X-WR-TIMEZONE:America/Los_Angeles
CALSCALE:GREGORIAN
BEGIN:VEVENT
ORGANIZER;CN=BB:MAILTO:email@gmail.com
DTSTAMP:20180208T150517Z
SUMMARY:Committee Meeting
UID:200893236
DTSTART:20180208T170000Z
DTEND:20180208T180000Z
DESCRIPTION:Adding event to your schedule does not confirm your reservation.\nVisit http://www.website.com for attendance details.
X-ALT-DESC;FMTTYPE=text/html:Adding event to your schedule does not confirm your reservation.\nVisit http://www.website.com for attendance details.
LOCATION:Conference Room
END:VEVENT
END:VCALENDAR
感谢任何指导!许多论坛都是关于这个主题的5-8岁,所以希望有一些最新的东西。
1)对于CR LF,使用:
echo chr(13).chr(10);
2)'折叠'我使用的东西:
function ical_split($value) {
/* "fold" any long content lines See: http://www.ietf.org/rfc/rfc2445.txt, section 4.1 */
$value = trim($value);
$lines = array();
while (strlen($value)>(75)) {
$line = mb_substr($value, 0, 75);
$llength = mb_strlen($line); // must use mb_strlen with mb_substr otherwise will not work things like
$lines[] = $line.chr(13).chr(10).chr(32); /* CRLF and space*/
$value = mb_substr($value, $llength); /* set value to what's left of the string */
}
if (!empty($value)) {
$lines[] = $value; /* the last line does not need a white space */
}
return (implode($lines));
}
3)描述中的链接。该规范不允许/解释说明中的html。一些应用程序可能会应对它,许多可能不会。最好的办法是放置原始网址,并希望接收应用程序将其转换为链接。这里有更多信息:https://icalevents.com/4019-ics-feed-generation-with-html/
请记住,您需要在行长度计算中包含整行,其中还包括文本“DESCRIPTION:”。首先完全创建该行并且有一个像anmari代码那样进行折叠的通用例程可能是个好主意。我最近收到了一些用户在我的验证器(iCalendar.org/validator.html)中报告可疑行长度计算错误的电子邮件,但他们的行长计算中没有包含“DESCRIPTION”。
“DESCRIPTION”仅适用于文本(欢迎使用1990年代!)。您在示例中使用“X-ALT-DESC”是正确的,这是描述文本的HTML版本,并且已成为描述中HTML的事实标准。您应该包括两者,因为“DESCRIPTION”是标准。