Generate .ics calendar files dynamically? (will pay you $$)

Discussion in 'PHP' started by drawer, May 25, 2011.

  1. #1
    I will tip you $$ from Paypal and add to your DP reputation if you solve this for us, thank you.

    I want to dynamically generate an .ics calendar file so that Outlook Calendar users etc. can save our events. This is a WordPress site, and each event will have it's own post under the "events" category.

    I found this code online, and it works, but we don't want this to automatically popup when users view the event page. Instead, we want a little button or link that says "add to Outlook Calendar" and then it pops up with a download/open box.

    In other words, the problem is really converting the below code to a "clickable" code...

    Anyway here is PHP code that works but needs hacking:

        <?php
        //This is the most important coding.
        header("Content-Type: text/Calendar");
        header("Content-Disposition: inline; filename=filename.ics");
        echo "BEGIN:VCALENDAR\n";
        echo "PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\n";
        echo "VERSION:2.0\n";
        echo "METHOD:PUBLISH\n";
        echo "X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n";
        echo "BEGIN:VEVENT\n";
        echo "CLASS:PUBLIC\n";
        echo "CREATED:20091109T101015Z\n";
        echo "DESCRIPTION:How 2 Guru Event\\n\\n\\nEvent Page\\n\\nhttp://www.myhow2guru.com\n";
        echo "DTEND:20091208T040000Z\n";
        echo "DTSTAMP:20091109T093305Z\n";
        echo "DTSTART:20091208T003000Z\n";
        echo "LAST-MODIFIED:20091109T101015Z\n";
        echo "LOCATION:Anywhere have internet\n";
        echo "PRIORITY:5\n";
        echo "SEQUENCE:0\n";
        echo "SUMMARY;LANGUAGE=en-us:How2Guru Event\n";
        echo "TRANSP:OPAQUE\n";
        echo "UID:040000008200E00074C5B7101A82E008000000008062306C6261CA01000000000000000\n";
        echo "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n";
        echo "X-MICROSOFT-CDO-IMPORTANCE:1\n";
        echo "X-MICROSOFT-DISALLOW-COUNTER:FALSE\n";
        echo "X-MS-OLK-ALLOWEXTERNCHECK:TRUE\n";
        echo "X-MS-OLK-AUTOFILLLOCATION:FALSE\n";
        echo "X-MS-OLK-CONFTYPE:0\n";
        //Here is to set the reminder for the event.
        echo "BEGIN:VALARM\n";
        echo "TRIGGER:-PT1440M\n";
        echo "ACTION:DISPLAY\n";
        echo "DESCRIPTION:Reminder\n";
        echo "END:VALARM\n";
        echo "END:VEVENT\n";
        echo "END:VCALENDAR\n";
        ?>
    
    Code (markup):
     
    drawer, May 25, 2011 IP