Skip to content

Instantly share code, notes, and snippets.

@Ahrengot
Last active October 23, 2016 00:44
Show Gist options
  • Save Ahrengot/5089358 to your computer and use it in GitHub Desktop.
Save Ahrengot/5089358 to your computer and use it in GitHub Desktop.
PHP generated .ics calendar download
<?php
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
echo "PRODID:-//Pumpehuset //NONSGML Pumpehuset//EN\n";
echo "METHOD:REQUEST\n"; // requied by Outlook
echo "BEGIN:VEVENT\n";
echo "UID:".date('Ymd').'T'.date('His')."-".rand()."-pumpehuset.dk\n"; // required by Outlok
echo "DTSTAMP:".date('Ymd').'T'.date('His')."\n"; // required by Outlook
echo "DTSTART:" . $_GET['year'] . $_GET['month'] . $_GET['day'] . 'T' . $_GET['time'] . "00\n";
//echo "DTSTART:20080413T000000\n";
echo "SUMMARY:" . $_GET['title'] . "\n";
echo "DESCRIPTION:" . $_GET['desc'] . "\n";
echo "END:VEVENT\n";
echo "END:VCALENDAR\n";
?>
<?php
$event_query = 'day=' . $d;
$event_query .= '&month=' . $m;
$event_query .= '&year=' . $y;
$event_query .= '&time=' . urlencode($time);
$event_query .= '&title=' . urlencode(get_the_title() . ' spiller i Pumpehuset');
$event_query .= '&desc=' . urlencode(get_the_title() . ' spiller i Pumpehuset');
$calendar_file = get_bloginfo('template_url') . '/library/event.php?' . $event_query;
$calendar_google_url = "http://www.google.com/calendar/event?action=TEMPLATE&text=". urlencode(html_entity_decode(get_the_title(), null, "UTF-8")) ."&dates=$googleTzStart/$googleTzEnd&details=". urlencode(html_entity_decode(get_the_excerpt(), null, "UTF-8")) ."&location=".urlencode("Pumpehuset, Studiestræde 52, 1554 København V, Denmark")."&trp=false&sprop=http%3A%2F%2Fpumpehuset.dk&sprop=name:Pumpehuset";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment