icalendar - webcal:// 协议 - 在 Chrome iOS 上创建 ical 提醒 - 从提示中隐藏订阅的 URL?
问题描述
我在网站上有一个按钮,可以在点击时添加日历事件。我在大多数浏览器上使用ics.js,但在 iOS 上的 Safari 上使用了不同的解决方案,而在 iOS 上使用 Chrome 浏览器时,我不得不实现 webcal:// 解决方案。
单击时,打开的 URL 是webcal://mysite.com?calreminder=[title]&time=[time]
然后服务器端我们生成这个输出:
function reminder_output()
{
if (isset($_GET['calreminder'])) {
$title = $_GET['calreminder'];
$time = $_GET['time'];
$now = new DateTime();
$start = new DateTime('tomorrow ' . $time);
// event duration is 10 minutes
$duration = new DateInterval('PT10M');
$end = $start->add($duration);
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="My-Site-Reminder.ics"');
$calData = array(
'BEGIN:VCALENDAR',
'PRODID:-//My Site//Reminder//EN',
'VERSION:2.0',
'BEGIN:VEVENT',
'RRULE:FREQ=DAILY;INTERVAL=1',
'DTSTAMP:' . $now->format('Ymd') . 'T' . $now->format('His'),
'UID:4088E990AD89VW3DBB4849094',
'DTSTART:' . $start->format('Ymd') . 'T' . $start->format('His'),
'DTEND:' . $end->format('Ymd') . 'T' . $end->format('His'),
'SUMMARY:' . $title,
'DESCRIPTION:' . $title,
'X-ALT-DESC;FMTTYPE=text/html:' . $title,
'END:VEVENT',
'END:VCALENDAR'
);
$calData = implode("\r\n", $calData);
echo $calData;
exit;
}
}
这将打开此提示:
这一切都很好,但理想情况下,我想从显示中隐藏 URL,而是显示事件的名称:“你想订阅 [Event Name] 吗?”
我知道一定可以做到,因为他们在https://www.addevent.com/add-to-calendar-button上做到了:
但是,我不知道如何以这种方式显示它而不是显示 URL。有人知道吗?
解决方案
出现在提示中的日历名称可以通过包括...来设置
X-WR-CALNAME:Your Custom Name
...在 ics 输出的正文中。
推荐阅读
- python - 如何将一组对象属性中的值传递给 tkinter 组合框值
- python - Python:一个多边形内的匀称的级联交叉点
- php - 真正的转义字符串到多个连接
- reactjs - 在 React 中使用 Dygraph 显示两个系列
- node.js - 带有查找和对象数组的 Mongoose 聚合
- php - 移动文件夹时,该文件夹中的所有引用都停止工作
- java - Java 注解看不到同一个注解类的私有字段
- java - 将列表从一个框架移动到另一个框架
- c# - WPF C#检查应用程序启动时是否存在所需文件
- wordpress - 使用 wp_enqueue_script() 添加 wordpress js