Enhance API functionality: add token generation methods, implement entry management, and improve setup process with settings storage
This commit is contained in:
1 parent
8ef5f7a941
commit
9316818753
9 files changed
+248
-25
No files matched your search
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// Load Main Library
|
||||
require "../api.php";
|
||||
|
||||
$api = new gbAPI(false);
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
|
||||
$api->answer(400, [
|
||||
"error" => "false_request_method",
|
||||
"error_text" => "Only POST allowed"
|
||||
]);
|
||||
}
|
||||
|
||||
$input = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if (!isset($input["name"]) || !isset($input["text"])) {
|
||||
$api->answer(400, [
|
||||
"error" => "missing_fields",
|
||||
"error_text" => "Some fields are missing"
|
||||
]);
|
||||
}
|
||||
|
||||
$api->getSetting("");
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// Load Main Library
|
||||
require "../api.php";
|
||||
|
||||
$api = new gbAPI(false);
|
||||
|
||||
// Get Entrys
|
||||
$command = "SELECT * FROM entrys WHERE status = :status";
|
||||
$result = $api->dbCommand($command, true, true, [":status" => 1]);
|
||||
|
||||
$entrys = [];
|
||||
|
||||
if (!$result) {
|
||||
$api->answer(200, [
|
||||
"entrys" => [],
|
||||
"empty" => true
|
||||
]);
|
||||
}
|
||||
|
||||
foreach($result as $row) {
|
||||
$entry_name = $row["name"];
|
||||
$entry_text = $row["text"];
|
||||
|
||||
$entry = [
|
||||
"name" => $entry_name,
|
||||
"text" => $entry_text
|
||||
];
|
||||
|
||||
$entrys[] = $entry;
|
||||
}
|
||||
|
||||
$json = json_encode($entrys);
|
||||
|
||||
$api->answer(200, [
|
||||
"entrys" => $entrys,
|
||||
"empty" => false
|
||||
]);
|
||||
Reference in new issue
Block a user