-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.php
25 lines (22 loc) · 795 Bytes
/
app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Kiota\Abstractions\ApiException;
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
set_include_path(__DIR__);
require 'vendor/autoload.php';
$tokenRequestContext = new ClientCredentialContext(
'517c3bf7-db40-48f4-95ef-479526a937bc',
'7c37e961-b7ce-49ac-a77f-d4cb6a20edb2',
'Hho8Q~6oRgDK15WDvhJzGVE5KA_m4GGYq4ftmagX'
);
$graphServiceClient = new GraphServiceClient($tokenRequestContext);
try {
$user = $graphServiceClient->users()->byUserId("[email protected]")->get()->wait();
if ($user != null) {
echo "Hello, I am {$user->getGivenName()}";
} else {
echo "There is no such user";
}
} catch (ApiException $ex) {
echo $ex->getError()->getMessage();
}