-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
22 lines (18 loc) · 759 Bytes
/
Copy pathindex.php
File metadata and controls
22 lines (18 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Rmorillo\JsonGenerator\JsonProcessor;
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
$jsonOriginalToArray = json_decode(file_get_contents("php://input"), true);
//Caso não tenha parâmetros, retorna erro.
if (empty($jsonOriginalToArray)) {
echo json_encode(['Message' => 'Erro: Nenhum parâmetro enviado']);
exit();
}
//Usa o JSONProcessor.
$jsonProcessor = new JsonProcessor($jsonOriginalToArray);
$jsonProcessor->process();
exit();