mbdax/ microsoftgraphbundle
Symfony2的API Micrososft扩展包
dev-master
2017-05-11 11:41 UTC
Requires
- php: >=5.6.0
- guzzlehttp/guzzle: 6.2.*
- league/oauth2-client: ^2.2
- microsoft/microsoft-graph: 0.1.*
This package is not auto-updated.
Last update: 2024-09-29 01:54:37 UTC
README
安装
将MicrosoftGraphBundle添加到您的项目中
建议通过Composer安装此扩展包。
$ composer require 'mbdax/microsoftgraphbundle:dev-master'
配置
您需要配置您的API
microsoft_graph: client_id: "%client_id%" client_secret: "%client_secret%" redirect_uri: "name of your redirect route" time_zone: "" # your prefered timezone default UTC version: "" version of API GRAPH: #1.0 or beta, deafault 1.0 stateless: true # if false, the state will stored in session scopes: # for more details https://developer.microsoft.com/en-us/graph/docs/authorization/permission_scopes - openid - offline_access #- ...
从Office 365 | API Graph获取令牌
// Get client service $client= $this->get('microsoft_graph.client'); try{ /* if you have a refresh token then the token will refresh */ $client->getNewToken(); }catch(\Exception $ex){ // else $client->redirect(); // redirect to office 365 authentication page }
示例:从Outlook日历获取事件
// Get calendar service $calendar= $this->get('microsoft_graph.calendar'); //Get a collection of Microsoft\Graph\Model\Event $startTime = new DateTime("first day of this month"); $endTime = new DateTime("first day of next month"); $events = $calendar->getEvents($startTime,$endTime); //Get a Microsoft\Graph\Model\Event $id='...' $event= $calendar->getEvent($id);
创建一个事件
// create Microsoft\Graph\Model\Event and set properties $newEvent= new Microsoft\Graph\Model\Event(); $start= $calendar->getDateTimeTimeZone(new \DateTime('Now next minute')); $end= $calendar->getDateTimeTimeZone(new \DateTime('Now next hour')); $newEvent->setSubject('Controller Test Token'); $newEvent->setStart($start); $newEvent->setEnd( $end); $event= $calendar->addEvent( $newEvent);
dump($event);
更新一个事件
$id='...' $updateEvent= new Microsoft\Graph\Model\Event(); $updateEvent->setId($id); $updateEvent->setSubject("I Forgot The Eggs!"); $event= $calendar->updateEvent( $updateEvent);
删除一个事件
$id='...' $response= $calendar->deleteEvent( $id); dump($response->getStatus()==204?"Event deleted":$response);
待办事项
抽象实体文档