dongliu1883 2017-04-06 08:07
浏览 63
已采纳

Outlook-web-app不会从我生成的icalendar中导入事件

For my application I use laravel 5.3 and a package called markuspoerschke/iCal which you can find here.

When a student wants to subscribe to his or her calender, we generate an URL which can be filled into Google Calender and Outlook. Except the last mentioned outlook it isn't importing any events.

Example of how our generated ICS looks like. This contains 1 event with the description of 'test'.

BEGIN:VCALENDAR 
VERSION:2.0 
PRODID:www.onderwijsonline.nl 
X-PUBLISHED-TTL:PT15M 
BEGIN:VEVENT 
UID:58e5f21fc2551 
DTSTART;TZID=Europe/Amsterdam:20170406T090000 
SEQUENCE:0 
TRANSP:OPAQUE DTEND;TZID=Europe/Amsterdam:20170406T140000 URL:http://oo.dev/calendar/event/420 
SUMMARY:Test 
CLASS:PUBLIC 
DTSTAMP:20170406T094535Z 
END:VEVENT 
END:VCALENDAR

The script that calls the package to generate this:

public function getIcal($token = null)
    {
        $user = $this->userRepository->getByToken($token);

        $vCalendar = new \Eluceo\iCal\Component\Calendar('www.onderwijsonline.nl');
        $vCalendar->setPublishedTTL('PT15M');

        if (!is_null($user)) {

            /**
             * Calendar events
             */
            $events = $this->calendarRepository->getEventsForUser($user->id, Carbon::now()->subWeeks(2), Carbon::now()->addWeeks(6));
            foreach ($events as $event) {

                $vEvent = new \Eluceo\iCal\Component\Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(Carbon::parse($event['start']))
                    ->setDtEnd(Carbon::parse($event['end']))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setUrl($event['href'])
                    ->setDescription($event['description'])
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }

            /**
             * Project events
             */
            $events = $this->calendarRepository->getEventsForProjects($user->id, null, null);

            foreach ($events as $event) {
                $vEvent = new \Eluceo\iCal\Component\Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(Carbon::parse($event['start']))
                    ->setDtEnd(Carbon::parse($event['end']))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setUrl($event['href'])
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }

            /**
             * Timetable events
             */
            $events = $this->calendarRepository->getEventsForTimetables($user->id, Carbon::now()->subWeeks(2), Carbon::now()->addWeeks(6));
            foreach ($events as $event) {
                $vEvent = new \Eluceo\iCal\Component\Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(Carbon::parse($event['start']))
                    ->setDtEnd(Carbon::parse($event['end']))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }
        }

        header('Content-Type: text/calendar; charset=utf-8');
        header('Content-Disposition: inline; filename=onderwijsonline.ics');

        return $vCalendar->render();
    }

As I've mentioned above, this exact setup works fine for Google Calendar, but is not for outlook.

Does anyone know why and how that can be fixed?

  • 写回答

1条回答 默认 最新

  • doumin4553 2017-04-21 09:54
    关注

    You are using a TZID=Europe/Amsterdam but your ics file does not include the VTIMEZONE definition corresponding to this TZID. So before your BEGIN:VEVENT, you should have a BEGIN:VTIMEZONE...END:VTIMEZONE component.

    As far as why it still works for Google but not for Outlook: A lot of products do use the Olson TZIDs so they can ignore the fact that the VTIMEZONE definition is missing and just assume that your TZID=Europe/Amsterdam corresponds to their mapping.

    Microsoft on the other hand has its own set of TZID identifiers (e.g. "Central Europe Standard Time") and hence can not map your Europe/Amsterdam to a known definition.

    Finally, on stack overflow at least your TRANSP, DTEND and URL property do appear on the same line. I'm assuming that this is just a formatting issue when submitting your question (???).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)