开发者

php generate webcal

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜