我试图让我的脚本生成一个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);
}发布于 2011-05-20 02:48:36
这是在你的控制器里吗?为什么不把它放在一个单独的“空白”布局中,而不是试图黑进控制器来做一些它不想做的事情。
// 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()可能需要的任何变量
https://stackoverflow.com/questions/6063136
复制相似问题