-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.php
More file actions
62 lines (52 loc) · 1.92 KB
/
main.php
File metadata and controls
62 lines (52 loc) · 1.92 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// Enable loading of Composer dependencies
use Microsoft\Graph\Generated\Models\ODataErrors\ODataError;
require_once realpath(__DIR__ . '/vendor/autoload.php');
require_once 'GraphHelper.php';
require_once realpath(__DIR__ . '/snippets/BatchRequests.php');
require_once realpath(__DIR__ . '/snippets/CreateRequests.php');
require_once realpath(__DIR__ . '/snippets/LargeFileUpload.php');
require_once realpath(__DIR__ . '/snippets/Paging.php');
// Load .env file
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__, ['.env', '.env.local'], false);
$dotenv->safeLoad();
$dotenv->required(['CLIENT_ID', 'TENANT_ID', 'GRAPH_USER_SCOPES'])->notEmpty();
$userClient = GraphHelper::getGraphClientForUser();
$user = $userClient->me()->get()->wait();
print('Hello, '.$user->getDisplayName().PHP_EOL);
$choice = -1;
while ($choice != 0) {
print('Please choose one of the following options:'.PHP_EOL);
print('0. Exit'.PHP_EOL);
print('1. Run batch samples'.PHP_EOL);
print('2. Run request samples'.PHP_EOL);
print('3. Run upload samples'.PHP_EOL);
print('4. Run paging samples'.PHP_EOL);
$choice = (int)readline('');
try {
switch ($choice) {
case 0:
print('Goodbye...'.PHP_EOL);
break;
case 1:
BatchRequests::runAllSamples($userClient);
break;
case 2:
CreateRequests::runAllSamples($userClient);
break;
case 3:
LargeFileUpload::runAllSamples($userClient);
break;
case 4:
Paging::runAllSamples($userClient);
break;
default:
print('Invalid choice!'.PHP_EOL);
}
} catch (ODataError $error) {
print('ERROR: '.$error->getError()->getMessage().PHP_EOL);
}
}
?>