You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1003 B
PHP
41 lines
1003 B
PHP
<?php
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
|
|
//include "brain/data/Auth.inc.php";
|
|
|
|
class APIControl
|
|
{
|
|
public static function start(
|
|
ServerRequestInterface $request,
|
|
ResponseInterface $response,
|
|
array $args
|
|
) {
|
|
$contentType = $request->getHeaderLine("Content-Type");
|
|
switch ($contentType) {
|
|
case "application/json":
|
|
$body = json_decode(file_get_contents("php://input"), true);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//there's only one verion of the api for now
|
|
switch (isset($args["third"]) ? $args["third"] : "none") {
|
|
case "login":
|
|
$result = (new Auth())->login($body);
|
|
break;
|
|
default:
|
|
$result = [
|
|
"message" => "Oh, nothing to do. That's unfortunate",
|
|
"type" => "TASK_NONE",
|
|
];
|
|
break;
|
|
}
|
|
|
|
$response->getBody()->write(json_encode($result));
|
|
return $response->withHeader("Content-Type", "application/json");
|
|
}
|
|
}
|