在我的网站上,我有一个按钮,当我点击此按钮时,我下载了一个名为" event.ics"的文件。在Iphone上,当文件被下载时,他会被自动阅读,我可以选择我的日历,但在Android和Windows Phone上,我需要点击下载的文件或进入文件夹"下载"执行.ics
。有没有办法在Android和WP上自动阅读/执行.ics
?
您可以在此处查看我的代码以下载日历文件:
public function createEventCalendar($start, $end, $description, $location)
{
$event = array();
$rand = rand(5, 1000000000);
$event['name'] = "event";
$event['data'] = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//TEST//TEST//EN\r\nBEGIN:VEVENT\r\nDTSTAMP:".date('Ymd\THis')."\r\nSTATUS:CONFIRMED\r\nUID:".$rand."\r\nDTSTART:".date('Ymd\THis', strtotime($start))."\r\nDTEND:".date('Ymd\THis', strtotime($end))."\r\nSUMMARY:Blablabla\r\nDESCRIPTION:".$description."\r\nLOCATION:".$location."\r\nEND:VEVENT\r\nEND:VCALENDAR";
return $event;
}
public function downloadEventCalendar($event)
{
$eventname = $event['name'].'.ics';
header("Content-Type: text/Calendar");
header("Content-Disposition: attachment; filename=\"".$eventname."\"");
echo $event['data'];
exit();
}
由于