prasadchinwal / microsoft-graph
用于操作Microsoft Graph API的包
v1.0.2
2024-08-28 16:12 UTC
Requires
- php: ^8.2
- illuminate/support: ^9.0|^10.0|^11.0
Requires (Dev)
- laravel/pint: ^1.10
- pestphp/pest: ^2.13
README
用于将Microsoft Graph API集成到Laravel应用程序的包装器。
安装
composer require prasadchinwal/microsoft-graph
- 运行
php artisan vendor:publish
并发布配置文件。 - 编辑
config/microsoft-graph.php
文件以配置您的设置。您需要租户、客户端ID和客户端密钥。
使用方法
用户API
-
获取用户:文档
检索所有用户。
$graph = MicrosoftGraph::users()->get(); dd($graph);
-
通过ID获取用户:文档
从principalName检索用户。
$graph = MicrosoftGraph::users() ->find('abc@user.com'); dd($graph);
日历API
-
获取用户日历:文档
检索用户的日历。
$graph = MicrosoftGraph::calendar() ->for('user_email') ->get(); dd($graph->first()->name); // To retrieve the name of the Calendar
-
获取用户日程安排:文档
检索用户的日程安排。
$users = ['usera@abc.com', 'userb@edf.com']; $graph = MicrosoftGraph::calendar() ->for('requester@xyz.com') ->schedule(users:$users, from: Carbon::now(), to: Carbon::now()->addDays(2), timezone: 'UTC', interval: 60); dd($graph);
-
获取用户的日历视图:文档
检索用户的日历视图。
MicrosoftGraph::calendar() ->for('user@xyz.com') ->view( start: \Carbon\Carbon::now()->toIso8601String(), end: \Carbon\Carbon::now()->toIso8601String(), );
事件API
-
获取用户日历事件:文档
检索用户的日历事件。
$graph = MicrosoftGraph::event() ->for('abc@xyz.com') ->get(); dd($graph->first()->subject); // To retrieve subject of first event.
您还可以过滤事件
有关所有过滤器列表,请参阅文档https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http。
$graph = MicrosoftGraph::event() ->for('abc@xyz.com') ->where("start/dateTime", "ge", "2024-04-17") ->where("end/dateTime", "le", "2024-04-26") ->get();
-
为用户创建新事件:文档
在用户的日历中创建事件。
- 使用
php artisan make:graph-event TestGraphEvent
生成事件类 - 根据需要编辑事件类,填写事件的相关详细信息。
$graph = MicrosoftGraph::event() ->create(new TestGraphEvent()); dd($graph);
- 更新用户现有事件:文档
更新用户的日历事件。
- 根据需要编辑事件类,填写事件的相关详细信息。
$graph = MicrosoftGraph::event() ->update( new TestGraphEvent(), eventId:'AAMk' ); dd($graph);
-
取消用户事件:文档
取消用户的日历事件。
$graph = MicrosoftGraph::event() ->for('pchin3@uisad.uis.edu') ->cancel(eventId: 'AAMk', message:"Cancelling via web request!"); dd($graph);
-
接受用户事件:文档
接受用户的日历事件。
$graph = MicrosoftGraph::event() ->for('abc@event.com') ->accept(eventId: 'AAMk', message:"Accepting via web request!"); dd($graph);
-
拒绝用户事件:文档
拒绝用户的日历事件。
- 根据需要编辑事件类,填写事件的相关详细信息。
$graph = MicrosoftGraph::event() ->for('abc@event.com') ->decline(eventId: 'AAMk', message:"Declining via web request!"); dd($graph);