Пример #1
0
require '../class/validation.php';
$db = new JsonDB("./data/");
$table_card = 'cards';
$table_set = 'sets';
$table_user = '******';
date_default_timezone_set("Asia/Bangkok");
$current_date = date('Y-m-d H:i:s');
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
//==================================== API SET =====================================
// GET:: Get all Sets
$app->get('/set', function () {
    global $db, $table_set;
    $app = \Slim\Slim::getInstance();
    // execute query
    $result = $db->selectAll($table_set);
    // response data
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($result);
});
// GET:: get detail of Set
$app->get('/set/:id', function ($id) {
    if (!is_numeric($id)) {
        http_response_code(400);
        echo json_encode(array('error' => 'id is must numeric!'));
        die;
    }
    global $db, $table_set;
    $app = \Slim\Slim::getInstance();
    $app->response()->header("Content-Type", "application/json");
    // prepare data