Skip to content
Snippets Groups Projects
get.php 789 B
Newer Older
root's avatar
root committed
<?php
namespace SmartData;

require_once('../bin/smartdata/SmartAPI.php');
use function SmartData\SmartAPI\get;
use SmartData\Exception\CustomException;
use SmartData\Logger;

http_response_code(HttpStatusCode::BAD_REQUEST);

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type, Content-length, X-Requested-With');
header("Access-Control-Allow-Methods: POST");

try {
    $content = file_get_contents('php://input');
    $response = get($content);
}catch(CustomException $e){
    http_response_code($e->getHTTPCodeError());
    Logger::exception($e);
    return false;
}catch(\Exception $e){
    http_response_code(HttpStatusCode::BAD_REQUEST);
    Logger::exception($e);
    return false;
}

http_response_code(HttpStatusCode::OK);
echo $response;