Exporting Single Google Calendar Events to ICS?

血红的双手。 提交于 2019-12-04 10:36:42

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';


?>

Some PHP Libraries I was able to dig up via google, all for PHP, I bet there are even more:

I also wanted to generate a .ics file for a single event. I didn't want to mess with PHP so I was going to use grymala's tip. Unfortunately I did not know the calendarID for the event I wanted to export so I exported all gcal's calendars and edited the resulting file so that it only contained the calendar heading, footing, and vevent lsiting. I also deleted the calendar name thought I don't know if this was necessary. I never did find out a way to get the url for a specific calendar as gymala suggested but I did find this based on this help text.

  1. In the calendar list on the left side of the page, move your mouse over the calendar you'd like to export from.

  2. You'll see a drop-down arrow appear next to the calendar name. Click the drop-down arrow and select Calendar settings. (Alternatively, click the drop-down arrow next to My calendars and select Settings, then click the appropriate calendar from the list.)

  3. Click the ICAL button in the 'Private Address' section at the bottom of the page, and click the displayed URL.

  4. Save the exported file to the desired folder on your computer. , possibly by pasting that URL into another browser window, copying the window text,and pasting it into an editor.

I realise how stale this is - but it came near top of the insidious search engine's ranking of how to get an ics of an individual event - none of the above worked for me, perhaps not surprisingly how old the thread is.

My solution - create a special calendar for the export of individual events - copy events you want exported to that calendar - export the calendar - then delete the events so it's clean for the next time - I was able to import individual events to T'bird.

I realise exporting a calendar with only 1 event in it is not quite the same as exporting a single event (or, perhaps it is) but it seems a useful work around.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!