Files
cwsvJudo/homepage/participo/api/shiai.php
marko f28fa7b51b WIP: bring participo back - consistent use of bootstrap - formatting -
phpstan level 0 error free - fixes for kyu subpage - move mams into
participo framework - remove legacy `lib/db.php` usage - add attributer
admin function - add newsposter - fixing apiKey creation
2025-11-19 12:24:38 +01:00

60 lines
1.4 KiB
PHP

<?php
require_once "bootstrap.php";
require_once "participoLib/shiai.php";
$method = $_SERVER["REQUEST_METHOD"];
// Sending Response
// - we send a json-formatted response
header("Content-Type: application/json");
// - check if an valid api key was send
// authorize();
participo::authentificate();
// - depending on the method we perform different actions
switch ($method) {
// Create
case "POST":
$postData = json_decode(file_get_contents("php://input"), true);
if (!$postData) {
die(
json_encode([
"error" => $postData . " not valid json data!",
])
);
}
die(json_encode(Shiai::fromArray($postData)->asArray()));
break;
// Read
case "GET":
echo json_encode(Shiai::dbSelect());
break;
// Update
case "PUT":
die(
json_encode([
"success" => false,
"reason" => $method . ".not supported yet.",
])
);
break;
// Delete
case "DELETE":
die(
json_encode([
"success" => false,
"reason" => $method . ".not supported yet.",
])
);
break;
// all other methods not supported
default:
die(
json_encode([
"success" => false,
"reason" => $method . ".not supported.",
])
);
}
?>