PHP code example of arharp / oauth2-planningcenter

1. Go to this page and download the library: Download arharp/oauth2-planningcenter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arharp / oauth2-planningcenter example snippets


$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...
}