PHP code example of prasadchinwal / microsoft-graph

1. Go to this page and download the library: Download prasadchinwal/microsoft-graph 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/ */

    

prasadchinwal / microsoft-graph example snippets


    $graph = MicrosoftGraph::users()->get();
    dd($graph);
    

    $graph = MicrosoftGraph::users()
   ->find('[email protected]');
    dd($graph);
    

    $graph = MicrosoftGraph::calendar()
        ->for('user_email')
        ->get();
    dd($graph->first()->name); // To retrieve the name of the Calendar
    

    $users = ['[email protected]', '[email protected]'];
    $graph = MicrosoftGraph::calendar()
        ->for('[email protected]')
        ->schedule(users:$users, from: Carbon::now(), to: Carbon::now()->addDays(2), timezone: 'UTC', interval: 60);
    dd($graph);
    

    MicrosoftGraph::calendar()
        ->for('[email protected]')
        ->view(
            start: \Carbon\Carbon::now()->toIso8601String(),
            end: \Carbon\Carbon::now()->toIso8601String(),
        );
    

    $graph = MicrosoftGraph::event()
        ->for('[email protected]')
        ->get();
    dd($graph->first()->subject); // To retrieve subject of first event.
    

    $graph = MicrosoftGraph::event()
            ->for('[email protected]')
            ->where("start/dateTime", "ge", "2024-04-17")
            ->where("end/dateTime", "le", "2024-04-26")
            ->get();
    

    $graph = MicrosoftGraph::event()
   ->create(new TestGraphEvent());
    dd($graph);
   

    $graph = MicrosoftGraph::event()
        ->update(
                new TestGraphEvent(),
                eventId:'AAMk'
            );
    dd($graph);
   

    $graph = MicrosoftGraph::event()
    ->for('[email protected]')
    ->cancel(eventId: 'AAMk', message:"Cancelling via web request!");
    dd($graph);
   

    $graph = MicrosoftGraph::event()
        ->for('[email protected]')
        ->accept(eventId: 'AAMk', message:"Accepting via web request!");
    dd($graph);
   

    $graph = MicrosoftGraph::event()
        ->for('[email protected]')
        ->decline(eventId: 'AAMk', message:"Declining via web request!");
    dd($graph);