-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
executable file
·53 lines (50 loc) · 1.52 KB
/
index.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
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
<?php require_once(__DIR__.'/common.php'); ?>
<!DOCTYPE html>
<html lang="en">
<?php require_once(__DIR__.'/header.php'); ?>
<body>
<?php require_once(__DIR__.'/navbar.php'); ?>
<div class="container" style="margin-top:80px">
<h1 class="text-center">Drive</h1>
<?php
require_once(__DIR__.'/vendor/autoload.php');
require_once(__DIR__.'/GoogleClient.php');
$response = \GoogleClient::getClient();
try{
if($response['success'] == 0){
echo $response['html'];
} else {
$client = $response['client'];
$service = new \Google_Service_Drive($client);
$optParams = array(
'pageSize' => 100,
'fields' => 'files'
);
$results = $service->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
echo "No files found<br>";
} else {
echo '<table class="table table-sm table-striped table-bordered" style="margin-top: 20px;">';
echo '<thead>';
echo '<tr><th>#</th><th>Name</th><th>ID</th></tr>';
echo '</thead>';
echo '<tbody>';
$s = 1;
foreach ($results->getFiles() as $file) {
echo '<tr><td>'.$s.'</td><td>'.$file->getName().'</td><td>'.$file->getId().'</td></tr>';
$s++;
}
die;
echo '</tbody>';
echo '</table>';
}
}
} catch(\Exception $e){
echo '<p>Exception occured:'.$e->getMessage().'</p>';
echo '<p>If issue is in Google api, remove data in token.json and refresh this page and try again.</p>';
}
?>
</div>
<?php require_once(__DIR__.'/footer.php'); ?>
</body>
</html>