Files
html/api/agent-avatars.php
2026-04-12 22:57:03 +02:00

23 lines
686 B
PHP

<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST");
$file = "/var/www/html/api/agent-avatars.json";
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = json_decode(file_get_contents('php://input'), true);
if ($data) {
file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT));
echo json_encode(["status" => "ok", "count" => count($data)]);
} else {
http_response_code(400);
echo json_encode(["error" => "invalid json"]);
}
} else {
if (file_exists($file)) {
echo file_get_contents($file);
} else {
echo "{}";
}
}