duanjia1870 2014-08-04 04:46 采纳率: 0%
浏览 153

将Outlook展示日历同步到您的日历

Good day,

I am working or basically coding with my own calendar application and I want to add my outlook calendar or sync the events from my outlook to my own calendar.

Is this possible ? if YES

Is there any good PHP plugins that I can use to do this kind of thing.

if NO

Can you explain why and can I know some alternatives or better solution to solve my problem. ?

Thank you.

  • 写回答

1条回答 默认 最新

  • duanke2012 2014-08-04 21:11
    关注

    Are you familiar with PHP COM Objects? Something like below would be ideal:

    <?php
    
    /**
     * This example uses COM() to Access Appointments
     * Requires Windows, Outlook
     *
     * @author justin DOT carlson AT gmail DOT com
     * @license none/free - sample code
    **/
    
    // define appointments array
    $appointments = array();
    
    // folder types (calendar, etc)
    define('olFolderDeleted', 3);
    define('olFolderOutbox', 4);
    define('olFolderSent', 5);
    define('olFolderInBox', 6);
    define('olFolderCalendar', 9);
    define('olFolderContacts', 10);
    define('olFolderJournal', 11);
    define('olFolderNotes', 12);
    define('olFolderTasks', 13);
    define('olFolderDrafts', 16);
    
    // start instance
    $outlook = new COM("Outlook.Application");
    $namespace = $outlook->getNameSpace("MAPI");
    $namespace->Logon();
    
    // get calendar folder
    $calendar = $namespace->GetDefaultFolder(olFolderCalendar);
    
    // gather, sort, and configure entries
    $entries = $calendar->Items;
    $entries->Sort("[Start]");
    $entries->IncludeRecurrences = True;
    
    // search filter, change these YYYY/MM/DD values for your date range
    $search = '[Start] >= "YYYY/MM/DD 12:00 am" AND [Start]<= "YYYY/MM/DD 11:59 pm"';
    
    // find entries
    $schedule = $entries->Find($search);
    
    while ( ! is_null($schedule) ) {
    
        $appointment = array();
        $appointment['allday'] = $schedule->AllDayEvent;
        $appointment['subject'] = $schedule->Subject;
        $appointment['hours'] = ($schedule->Duration / 60);
        $appointment['location'] = $schedule->Location;
        $appointment['subject'] = $schedule->Subject;
        $appointment['body'] = $schedule->Body;
        $appointment['categories'] = $schedule->Categories;
        $appointment['start'] = date('m/d/Y h:i:s a', variant_date_to_timestamp($schedule->Start));
        $appointment['end'] = date('m/d/Y h:i:s a', variant_date_to_timestamp($schedule->End));
        $appointment['stamp'] = variant_date_to_timestamp($schedule->Start);
        $appointments[] = $appointment;
        $schedule = $entries->FindNext();
    
    }
    
    // $appointments now contains your entries, enjoy!
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算