How can I use PHP to dynamically publish an ical file to be read by Google Calendar?
This should be very simple if Google Calendar does not require the *.ics
-extension (which will require some URL rewriting in the server).
$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "@yourhost.test
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR";
//set correct content-type-header
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
echo $ical;
exit;
That's essentially all you need to make a client think that you're serving a iCalendar file, even though there might be some issues regarding caching, text encoding and so on. But you can start experimenting with this simple code.
Dynamic .ics from php not updating in Google Calendar
csanyigabor is correct. Also you must ensure that the UID's are the same so that the application will match the events.
This question and answer here deals with cancelations, but the principle is the same
How to cancel an calendar event using ics files?
Related Topics
Why Are Floating Point Numbers Printed So Differently
What Does Double Question Mark () Operator Mean in PHP
How to Password Protect Folder/Page Using PHP Without a Db or Username
How to Get Previous Month and Year Relative to Today, Using Strtotime and Date
Download Files from Server PHP
PHP Daylight Saving Time Detection
Pdostatement (Mysql): Inserting Value 0 into a Bit(1) Field Results in 1 Written in Table
Redirect with PHP After Ajax Call
Unset a Column in a Multidimensional Array
How to Access a Deep Object Property Named as a Variable (Dot Notation) in PHP
How to Trim White Spaces of Array Values in PHP
Detecting Image Type from Base64 String in PHP
Casperjs Passing Data Back to PHP
How Get All Values in a Column Using PHP