使用PHP为Outlook Meeting事件创建ICS

问题描述 投票:0回答:1

尝试从php生成.ics,到目前为止没有成功。该文件已创建(它下载到我的/ downloads文件夹),但是当我点击下载的ics事件时,没有任何反应,Outlook中没有弹出窗口。这是我试过的:

$company='company';//$_GET['company'];
$proj_title='projtitle';//$_GET['proj_title'];
$proj_num='project number';//$_GET['proj_num'];
$subject='subject';//$_GET['subject'];
$subject=$proj_num.' '.$company.' - '.$proj_title.': '.$subject;

$http='http%3A%2F%2F';
$fwd_slash='%2F';
$question_mark='%3F';
$equals='%3D';
$ampersand='%26';

$description='Brief description of meeting.';

/* begin ical */
$meeting_date=date('Y-m-d')." 09:00:00";
$meeting_duration=3600;

$meeting_stamp=strtotime($meeting_date." UTC");
$dtstart=gmdate("Ymd\THis\Z",$meeting_stamp);
$dtend=gmdate("Ymd\THis\Z",$meeting_stamp+$meeting_duration);

/* set up the event properties */
$event=array(
    'id'          => $proj_num,
    'subject'     => $subject,
    'description' => $description,
    'datestart'   => $dtstart,
    'dateend'     => $dtend,
    'location'    => 'Boardroom'
);

/* build the ics file */
$ical='BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTEND;TZID="America/New_York":'.$dtend.'
UID:'.md5($event['subject']).'
DTSTAMP:'.time().'
LOCATION:'.addslashes($event['location']).'
DESCRIPTION:'.addslashes($event['description']).'
URL;VALUE=URI:http://tracker/ics/'.$event['id'].'
SUMMARY:'.addslashes($event['subject']) . '
BEGIN:VALARM
TRIGGER:-PT30M
REPEAT:1
DURATION:PT15M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM'.'
DTSTART;TZID="America/New_York":'.$dtstart.'
END:VEVENT
END:VCALENDAR';

/* set correct content-type-header */
if($event['id']){
    header('Content-type: text/calendar; charset=utf-8');
    header('Content-Disposition: attachment; filename=tracker_event.ics');
    echo $ical;
}
else{
    header('Location: /');
}

我对icalendar活动相对较新,并且在网上详尽地研究了上面提到的代码,使用虚拟值取得了一些成功,直到现在我需要用真实数据替代。

任何帮助是极大的赞赏。

php icalendar
1个回答
0
投票

解决了。问题是我将HTML内容添加到ICS的DESCRIPTION部分。我完全删除了DESCRIPTION,并将其替换为:

X-ALT-DESC;FMTTYPE=text/html:<html>'.$html.'</html>

$ html将您希望显示的内容(在Outlook 2016中,我的部署环境)存储为HTML格式的内容。

现在一切都按照我需要的方式运作。希望有一天能帮助别人。

© www.soinside.com 2019 - 2024. All rights reserved.