<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Keep2Share Files</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1 class="mt-5 mb-4">Keep2Share Files</h1>
<?php
require_once('Keep2SAPI.php');
$apiToken = 'myToken';
$api = new Keep2ShareAPI();
$api->access_token = $apiToken;
// Validate token
$validateResponse = $api->validateToken();
if ($validateResponse['status'] == 'success') {
echo "<p class='alert alert-success'>Token validation successful.</p>";
// Function to recursively fetch files within folders
function fetchFiles($api, $parentId = null)
{
$response = $api->getFilesList($parentId);
if ($response['status'] == 'success') {
$items = $response['files'];
foreach ($items as $item) {
if (!$item['is_folder']) {
echo "<li class='list-group-item'>" . $item['name'] . "</li>";
} else {
fetchFiles($api, $item['id']); // Recursive call for subfolders
}
}
} else {
echo "<p class='alert alert-danger'>Error fetching files: " . $response['message'] . "</p>";
}
}
echo "<ul class='list-group'>";
fetchFiles($api);
echo "</ul>";
} else {
echo "<p class='alert alert-danger'>Token validation failed. Please check your API token.</p>";
}
?>
</div>
</body>
</html>