arharp/oauth2-planningcenter

league/oauth2-client 的 Planning Center 提供商

1.0 2024-04-05 15:01 UTC

This package is auto-updated.

Last update: 2024-09-05 16:31:45 UTC


README

本软件包提供了PlanningCenter集成,用于League的OAuth2客户端

安装

composer require arharp/oauth2-planningcenter

用法

以下是一个基本示例,展示如何认证用户。

通过在您的开发者账户中创建应用程序来获取客户端ID和密钥。

$provider = new Arharp\OAuth2\Client\Provider\PlanningCenter([
    'clientId' => 'CLIENT_ID',
    'clientSecret' => 'SECRET',
    'redirectUri' => 'https://example.org/endpoint',
]);

if (! isset($_GET['code'])) {
    # Get the authorization URL...
    $url = $provider->getAuthorizationUrl(['scope' => 'people giving']);
    
    # Redirect the user...
    header('Location: ' . $url);
    
    exit;
    
} else {
    # Get the access token
    $accessToken = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);
    
    # Do something with the access token...
}