开发者

php generate webcal

开发者 https://www.devze.com 2023-03-07 06:30 出处:网络
I am trying to get my script to generate an iCalendar, but mac calendar program keeps telling me the data is invalid.I\'m using cakephp.Here\'s what I have -- any clues?:

I am trying to get my script to generate an iCalendar, but mac calendar program keeps telling me the data is invalid. I'm using cakephp. Here's what I have -- any clues?:

function webcal() {
    Configure::write('debug', 0); 
    $this->autoRender = false; 
    echo header( 'Content-Type: text/calendar; charset=utf-8' );  
    ?>
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:uid1@example.com
DTSTAMP开发者_如何学编程:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:20110514T170000Z
DTEND:20110515T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR
    <?php
    exit(200);      
}


is this in your controller? why not put it in a seperate "blank" layout instead of trying to hack the controller to do something it's not meant to do.

// controller code
function webcal(){
    Configure::write('debug', 0); 
    echo header( 'Content-Type: text/calendar; charset=utf-8' );  
    $this->layout = 'blank' // depending on what version of cakephp you're using this might be different
}

// layout code in /app/views/layout/blank.ctp
echo $content_for_layout;

// view code in /app/views/<controller>/webcal.ctp
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:uid1@example.com
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:20110514T170000Z
DTEND:20110515T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

don't forget to pass the view any variables you may need with $this->set()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号