PHP code example of niisan / laravel-oauth-google-calendar

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

    

niisan / laravel-oauth-google-calendar example snippets


    private OauthCalendarService $oauthCalendarService;

    public function __construct(OauthCalendarService $oauthCalendarService)
    {
        $this->oauthCalendarService = $oauthCalendarService;
    }

    $service = app(OauthCalendarService::class);


return [
    'scopes' => [
        'profile',
        'email',
        'https://www.googleapis.com/auth/calendar.events',
    ],
    'redirect' => env('GOOGLE_CALENDAR_OAUTH_REDIRECT_URL', 'https://example.com/auth/callback'),
    'client_id' => env('GOOGLE_CALENDAR_CLIENT_ID', ''),
    'client_secret' => env('GOOGLE_CALENDAR_CLIENT_SECRET', ''),
    'events' => [
        'token_refreshed' => ''
    ],
    'holiday_id' => env('GOOGLE_CALENDAR_HOLIDAY_ID', '[email protected]'),
];

'events' => [
    'token_refreshed' => TokenRefreshedEvent::class
]

class TokenRefreshedEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($user, array $token)
    {
        //
    }

public function getEventList($user, $config): array;
public function createEvent($user, array $data): Google_Service_Calendar_Event;
public function deleteEvent($user, $event_id);

$config = [
    'orderBy' => null,
    'search' => 'test',
    'timeMax' =>'2021-01-01',
    'timeMin' => '2020-12-01',
    'timeZone' => 'Asia/Tokyo',
    'updatedMin' => null
    'maxResults' => 150,
    'singleEvents' => true
];

$data = [
    'summary' => 'abcd',
    'description' => 'efgh',
    'start' => '2021-02-21 12:00:00',
    'end' => '2021-02-21 13:00:00'
];

public function getFreeBusy($user, $config): array

[
    [
        'start' => '2021-06-01T02:00:00Z'
        'end' => '2021-06-01T04:00:00Z'
    ],
    [
        'start' => '2021-06-07T02:00:00Z'
        'end' => '2021-06-07T04:00:00Z'
    ],
]

php artisan vendor:publish