好吧,一直在兜圈子,试图将内容放在新的一行或折叠上。我已经尝试了两个验证器并且可以使其有效,但它给了我行长度警告 - https://icalendar.org/validator.html
我不知道如何按照规范中的描述输入 CRLF - https://www.rfc-editor.org/rfc/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);
Run Code Online (Sandbox Code Playgroud)
目前的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";
Run Code Online (Sandbox Code Playgroud)
除了新行问题之外,我想在描述中添加一个链接。希望解决方案在 Apple Calendar、Google 和 Outlook 中有效且有效。
集成电路输出
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
Run Code Online (Sandbox Code Playgroud)
感谢任何指导!许多论坛在这个主题上已经有 5-8 年历史了,所以希望能有一些最新的东西。
1) 对于 CR LF,使用:
echo chr(13).chr(10);
Run Code Online (Sandbox Code Playgroud)
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));
}
Run Code Online (Sandbox Code Playgroud)
3) 描述中的链接。该规范不允许/在描述中使用 html。有些应用程序可以处理它,但许多应用程序可能无法处理。最好的办法是输入原始 URL,并希望接收应用程序将其转换为链接。这里有更多信息:https://icalevents.com/4019-ics-feed- Generation-with-html/