Use example.com instead of domain.de/game references to make the skeleton truly generic and not tied to any specific project.
18 lines
529 B
PHP
18 lines
529 B
PHP
<?php
|
|
/**
|
|
* api.example.com — REST API
|
|
*/
|
|
header('Content-Type: application/json');
|
|
$method = $_SERVER['REQUEST_METHOD'];
|
|
switch ($method) {
|
|
case 'GET':
|
|
echo json_encode(['status' => 'ok', 'message' => 'API läuft']);
|
|
break;
|
|
case 'POST':
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
echo json_encode(['status' => 'received', 'data' => $input]);
|
|
break;
|
|
default:
|
|
http_response_code(405);
|
|
echo json_encode(['error' => 'Method not allowed']);
|
|
} |