PHP code example of sdksio / google-calendar-apimatic-sdk

1. Go to this page and download the library: Download sdksio/google-calendar-apimatic-sdk 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/ */

    

sdksio / google-calendar-apimatic-sdk example snippets


use CalendarApiLib\Logging\LoggingConfigurationBuilder;
use CalendarApiLib\Logging\RequestLoggingConfigurationBuilder;
use CalendarApiLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
use CalendarApiLib\Environment;
use CalendarApiLib\Authentication\AuthorizationCodeAuthCredentialsBuilder;
use CalendarApiLib\Models\OauthScope;
use CalendarApiLib\CalendarApiClientBuilder;

$client = CalendarApiClientBuilder::init()
    ->authorizationCodeAuthCredentials(
        AuthorizationCodeAuthCredentialsBuilder::init(
            'OAuthClientId',
            'OAuthClientSecret',
            'OAuthRedirectUri'
        )
            ->oauthScopes(
                [
                    OauthScope::HTTPS_WWW_GOOGLEAPIS_COM_AUTH_CALENDAR_READONLY,
                    OauthScope::HTTPS_WWW_GOOGLEAPIS_COM_AUTH_CALENDAR_EVENTS
                ]
            )
    )
    ->environment(Environment::PRODUCTION)
    ->loggingConfiguration(
        LoggingConfigurationBuilder::init()
            ->level(LogLevel::INFO)
            ->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
            ->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
    )
    ->build();