能否创建预填充指定URL的Google日历订阅链接?
实现Google日历订阅链接的自动预填充
当然存在这样的功能,你可以构造特定格式的Google日历链接,让用户点击后直接跳转到添加日历的页面,并自动预填充目标日历URL,完全不需要手动复制粘贴。
具体实现步骤:
- 替换协议:将你的
webcal://开头的链接替换为https://,因为Google日历的订阅参数仅支持HTTP/HTTPS协议。
你的原链接:webcal://domain.co.uk/calendar/export.php?Staff=Mr+Alan+Smith
替换后:https://domain.co.uk/calendar/export.php?Staff=Mr+Alan+Smith - URL编码:对替换后的链接进行URL编码处理,得到编码后的字符串:
https%3A%2F%2Fdomain.co.uk%2Fcalendar%2Fexport.php%3FStaff%3DMr%2BAlan%2BSmith - 拼接最终链接:将编码后的字符串拼接到Google日历的订阅跳转链接中,格式如下:
对应你的情况,最终链接为:https://calendar.google.com/calendar/u/0/r?cid=编码后的日历链接https://calendar.google.com/calendar/u/0/r?cid=https%3A%2F%2Fdomain.co.uk%2Fcalendar%2Fexport.php%3FStaff%3DMr%2BAlan%2BSmith
用户点击这个最终链接后,会直接进入Google日历的添加日历页面,目标URL已经自动填充到输入框内,只需点击“添加日历”就能完成订阅。
另外,也可以使用简化版的跳转链接格式,效果完全一致:
https://calendar.google.com/calendar/r/add?cid=https%3A%2F%2Fdomain.co.uk%2Fcalendar%2Fexport.php%3FStaff%3DMr%2BAlan%2BSmith
内容的提问来源于stack exchange,提问作者Henry Aspden
相关产品推荐
相关产品推荐

