Пример #1
0
        sendResponse(400, initBody(true, "An error occurred."), null);
    }
});
$app->delete('/users/:userId/friends/:friendId', 'checkToken', function ($userId, $friendId) use($app) {
    $db = new dbHandler();
    if ($db->deleteFriend($userId, $friendId)) {
        sendResponse(204, initBody(false, null), null);
    } else {
        sendResponse(400, initBody(true, "An error occurred."), null);
    }
});
$app->post('/feedback', 'checkToken', function () use($app) {
    $db = new dbHandler();
    $token = $app->request->headers->get('token');
    $message = $app->request->post('message');
    if ($db->sendFeedback($token, $message)) {
        sendResponse(201, initBody(false, null), null);
    } else {
        sendResponse(400, initBody(true, "An error occurred."), null);
    }
});
/*EVENT*/
$app->get('/events/:id', function ($id) use($app) {
    $db = new dbHandler();
    if ($event = $db->getEvent($id)) {
        if (($user = $db->getEventUser($id)) && ($participants = $db->getEventParticipants($id))) {
            $event = $event->fetch_array(MYSQLI_ASSOC);
            $event['user'] = $user->fetch_array(MYSQLI_ASSOC);
            $array_participants = array();
            while ($participant = $participants->fetch_assoc()) {
                array_push($array_participants, $participant);