要将单个Google日历活动导出到ICS? [英] Exporting Single Google Calendar Events to ICS?

查看:177
本文介绍了要将单个Google日历活动导出到ICS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究在网页上显示来自多个Google日历的事件列表的可能性.目前,我正在使用适用于WordPress的Google Calendar Events插件在站点(防火墙后面的开发站点,因此无法共享链接)上显示事件;但我想看看是否有任何简单的方法可以为每个事件动态生成ICS文件.

I am currently looking into the possibility of displaying lists of events from multiple Google Calendars on a Web page. At the moment, I'm using the Google Calendar Events plugin for WordPress to display the events on the site (development site behind a firewall, so I can't share a link); but I'd like to see if there's any simple method to dynamically generate ICS files for each individual event.

我们希望允许网站访问者将单个事件添加到他们的日历中,但是Google Calendar Data API似乎仅提供了以ICS格式下载整个日历的选项.我只是尝试将带有eid(事件ID)的查询字符串附加到ICAL提要地址的末尾,但这仍然会打开标准的Google ICAL提要,其中包括日历中当前包含的所有事件.

We would like to allow the website visitors to add individual events to their calendars, but the Google Calendar Data API only seems to provide the option to download an entire calendar in ICS format. I tried simply appending a query string with the eid (event ID) to the end of the ICAL feed address, but that still opens the standard Google ICAL feed, which includes all of the events currently included on the calendar.

我对从头开始动态构建ICS文件有点熟悉,并且过去做过一次,从本地Perl日历程序中提取事件并为每个事件生成ICS文件.但是如果已经设置了任何预构建的API或PHP类,以通过单个Google日历事件构建ICS文件,则我更希望使用它们.

I am somewhat familiar with dynamically building ICS files from scratch, and have done it once in the past, pulling events from a local Perl calendar program and generating an ICS file for each event; but if there are any pre-built APIs or PHP classes that are already set up to build ICS files from individual Google Calendar Events, I'd much prefer to use those.

推荐答案

它真的很简单,只是一个页面,请尝试以下操作:(当然,您需要替换自己的变量...)

Its so simple its just a page really, try this: (you'll need to substitute you own variables of course ...)

<?php
    /*
    * generates calendar ics file
    */ 

if( 
    empty($_GET['summary']) || 
    empty($_GET['dtstart']) || 
    empty($_GET['dtend']) 
){
header ("Location: /diary/this-week") ;
exit();
} 

  header("Content-type: text/calendar");
  header("Content-Disposition: attachment; filename=".urlencode($_GET['summary']).'-'.time().".ics");
  header("Pragma: no-cache");
  header("Expires: 0");
  echo 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:councilsites
METHOD:PUBLISH
BEGIN:VEVENT
URL:'. htmlentities( $_GET['url'] ) .'
UID:'. htmlentities( $_GET['url'] ) .'
SUMMARY:'. htmlentities( $_GET['summary'] ) .'
DTSTAMP:'. date('Ymd\THis\Z') .'
DTSTART:'. htmlentities( $_GET['dtstart'] ) .'
DTEND:'. htmlentities( $_GET['dtend'] ) .'
LOCATION:'. htmlentities( $_GET['location'] ) .' 
END:VEVENT
END:VCALENDAR';


?>

这篇关于要将单个Google日历活动导出到ICS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆