#native_company# #native_desc#
#native_cta#

Using PHP to Make Basic vCalendar/iCalendar Events Page 2

By PHP Builder Staff
on October 30, 2002

MIME Type Setups

A standard vCalendar file has an extension of .vcs and MIME type of text/x-vCalendar. If you use iCalendar, the MIME type is “text/Calendar” and the extension is .ics.
You’ll need to tell Apache to send the linked-to file to PHP for parsing, and then tell PHP to send it with the vCalendar MIME type. The easiest way to do this is to have a .php file that sends a stream of data as a vCalendar file to the browser. This is accomplished by calling the header function at the very top of your script. For vCalendars:

<?php

    header
("Content-Type: text/x-vCalendar");

    
header("Content-Disposition: inline; filename=MyvCalFile.vcs");

?>



An alternative is to have a .vcs or .ics file with PHP code, but you’ll need to make the appropriate changes to your server’s httpd.conf and mime.types files. Add .vcs (or .ics) to httpd.conf’s AddType application/x-httpd-php line and add the appropriate MIME type to your mime.types file.
On the client side, the browser must have the text/x-vCalendar MIME type registered, and, ideally, it should be told to directly open up the vCalendar file with the calendaring application. Most browsers should have this pre-configured. The rest will probably prompt the user for the application to open the file with. You may want to include help text on what this .vcs file does, and, if necessary, how to configure MIME type settings.