php生成网络摄像头

时间:2011-05-19 18:22:32

标签: php cakephp icalendar vcalendar

我正在尝试让我的脚本生成iCalendar,但是mac日历程序一直告诉我数据无效。我正在使用cakephp。这就是我所拥有的 - 任何线索?:

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);      
}

1 个答案:

答案 0 :(得分:0)

这是你的控制器吗?为什么不把它放在一个单独的“空白”布局中,而不是试图破解控制器做一些它本不应该做的事情。

// 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

不要忘记使用$this->set()

传递您可能需要的任何变量