spaanproductions / office365-laravel
为 Laravel 9.0 或更高版本提供的 Office365 包
v0.0.4
2022-12-07 12:24 UTC
Requires
- php: >=8.0
- illuminate/support: ^9.0.0
- league/oauth2-client: ^2.6.0
- microsoft/microsoft-graph: ^1.0.0
README
为 Laravel 9.0 或更高版本提供的 Office365 包
安装
composer require spaanproductions/office365-laravel
此包将自动在 Laravel 中注册 ServiceProvider。
SpaanProductions\Office365\Office365ServiceProvider::class,
您可以可选地发布配置文件。
php artisan vendor:publish --provider="SpaanProductions\Office365\Office365ServiceProvider"
从 应用程序注册门户 获取您的应用程序 ID 和密钥
然后将它们放入 环境 文件中
OFFICE365_TENANT_ID=
OFFICE365_CLIENT_ID=
OFFICE365_CLIENT_SECRET=
OFFICE365_OBJECT_ID=
OFFICE365_REDIRECT_URI=https://:8000/redirect
OFFICE365_SCOPES='openid profile offline_access User.Read Mail.Read'
示例用法
<?php
namespace App\Http\Controllers;
use SpaanProductions\Office365\Facade\Office365;
class AuthController extends Controller
{
public function signin()
{
$link = Office365::login();
return redirect($link);
}
public function redirect()
{
if (!request()->has('code')) {
abort(500);
}
$code = Office365::getAccessToken(request()->get('code'));
$user = Office365::getUserInfo($code['token']);
$messages = Office365::getEmails($code['token']);
dd($user, $messages);
}
}
此包支持的方法及其参数可以在 API 参考 中找到
问题
如果您有任何问题或问题,请打开一个 Issue。