fungio/outlook-calendar-bundle

为您的Symfony 3项目提供Outlook日历集成。

dev-master / 4.3.x-dev 2021-10-20 09:48 UTC

This package is auto-updated.

Last update: 2024-09-20 16:06:37 UTC


README

此捆绑包使用Outlook API列出Outlook日历中的事件。

请随时贡献、分支、发送合并请求和创建工单。

要求

创建API账户

访问应用程序注册门户:https://apps.dev.microsoft.com

点击“添加应用程序”并给你的应用程序命名。

点击“生成新密码”并复制密码

安装

步骤 1: 安装OutlookCalendarBundle

运行

composer require fungio/outlook-calendar-bundle:dev-master

步骤 2: 启用捆绑包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Fungio\OutlookCalendarBundle\FungioOutlookCalendarBundle()
    ];
}

步骤 3: 配置

# app/config/parameters.yml

fungio_outlook_calendar:
    outlook_calendar:
        client_id: "YOUR_APPLICATION_ID"
        client_secret: "THE_PASSWORD_YOU_SAVED"

示例

<?php
// in a controller
$request = $this->get('request_stack')->getMasterRequest();
$session = new Session();

$outlookCalendar = $this->get('fungio.outlook_calendar');
if ($session->has('fungio_outlook_calendar_access_token')) {
    // do nothing
} else if ($request->query->has('code') && $request->get('code')) {
    $token = $outlookCalendar->getTokenFromAuthCode($request->get('code'), $redirectUri);
    $access_token = $token['access_token'];
    $session->set('fungio_outlook_calendar_access_token', $access_token);
} else {
    return new RedirectResponse($outlookCalendar->getLoginUrl($redirectUri));
}

$events = $outlookCalendar->getEventsForDate($session->get('fungio_outlook_calendar_access_token'), new \DateTime('now');