I have been trying to create a .ics page in php which is to be added to Google Calendar via "Add by URL" in order for me to retrieve events from a database and present them in the calendar.
I have searched around a while on SO and found another post which was very helpful in getting started, but I have now hit a snag which doesn't seem to affect those with similar code. Post can be found here.
So, my problem is that I cannot seem to get the Google Calendar to update my page, as if it has cached the page within the calendar. So when I add another VEVENT to the page it does not update the calendar.
When creating the file it generates the correct format for an *.ics file. Format shown below.
If I go directly to the page I do get prompted to download the file, which works to import into GC, and if I add the same code to a different page, for instance changing the pages name from cal.php to cal2.php, will make GC read all of the events whilst when I simply add the same URL as before it does not pick up on any changes made to the file.
Anyone have any idea to why this isn't updating?
Others who have had similar problems have solved this by adding a UID to their VEVENT, which did not solve this anything for me...
Format generated
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:17d88c861131ec62f18835cdd4eb7d0c@yourhost.test
DTSTAMP:20110901T092002Z
DTSTART:20110925T170000Z
DTEND:20110928T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
BEGIN:VEVENT
UID:00813115d1a2d21447eb11ded3ba9020@yourhost.test
DTSTAMP:20110901T092002Z
DTSTART:20110929T170000Z
DTEND:20110930T035959Z
SUMMARY:Camping Trip
END:VEVENT
BEGIN:VEVENT
UID:1f18d85fe516d684536129ed066e7d4f@yourhost.test
DTSTAMP:20110901T092002Z
DTSTART:20110914T170000Z
DTEND:20110915T035959Z
SUMMARY:Testing new Event
END:VEVENT
END:VCALENDAR
Code used
<?php
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=\"calendar.ics\"");
echo "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:20110925T170000Z
DTEND:20110928T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "@yourhost.test
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
DTSTART:20110929T170000Z
DTEND:20110930T035959Z
SUMMARY:Camping Trip
END:VEVENT
BEGIN:VEVENT
UID:" . md5(uniqid(mt_rand(), true)) . "@yourhost.test
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
DTSTART:20110914T170000Z
DTEND:20110915T035959Z
SUMMARY:Testing new Event
END:VEVENT
END:VCALENDAR";
?>