Files
projet_programmation_web/ProjetProgWeb/api.php
T
2021-10-31 00:19:53 +02:00

21 lines
473 B
PHP

<?php
require_once("class/dump.php");
if (!isset($_GET['q']) || !isset($_GET['author'])) {
print_r(json_encode(array("status" => 400, "message" => "Missing query type or attributs.")));
exit();
}
$author_name = $_GET['author'];
$q = $_GET['q'];
$json_object = match ($q) {
"theses" => dump::getTheseByAuthor($author_name),
"authors" => dump::getAuthorsByAuthors($author_name),
default => NULL,
};
$json = json_encode($json_object);
print_r($json);