Ejemplo n.º 1
0
            $response["message"] = "Failed to create customer. Please try again";
            echoResponse(201, $response);
        }
    } else {
        $response["status"] = "error";
        $response["message"] = "An user with the provided phone or email exists!";
        echoResponse(200, $response);
    }
});
$app->get('/profile', function () {
    session_start();
    $user_id = $_SESSION['nc_uid'];
    $near_db = new near_query_handler();
    $user = $near_db->getOneRecord("select * from user where id='{$user_id}'");
    echoResponse(200, $user);
});
$app->get('/getvenuesbyuser', function () {
    session_start();
    $user_id = $_SESSION['nc_uid'];
    $near_db = new near_query_handler();
    $venue = $near_db->getRecords("select * from venue where user_id='{$user_id}'");
    $data = array('venue' => $venue);
    echoResponse(200, $venue);
});
$app->get('/logout', function () {
    $n_session = new near_session();
    $session = $n_session->destroySession();
    $response["status"] = "info";
    $response["message"] = "Logged out successfully";
    echoResponse(200, $response);
});
Ejemplo n.º 2
0
        $response["status"] = "success";
        $response["message"] = "Comment added successfully";
        echoResponse(200, $response);
    } else {
        $response["status"] = "error";
        $response["message"] = "Failed to add comment";
        echoResponse(201, $response);
    }
});
// GET Comments
$app->get('/getcomments/:id', function ($id) use($app) {
    $near_db = new near_query_handler();
    $comments = $near_db->getComments($id);
    $app->response()->header("Content-Type", "application/json");
    $response["venue"] = $id;
    $response["comments"] = $comments;
    echoResponse(200, $response);
});
//delete comment
$app->post('/deletecomment', function () use($app) {
    $r = json_decode($app->request->getBody());
    $comment_id = $r->comment_id;
    $near_db = new near_query_handler();
    $deletecomment = $near_db->deleteRecord("DELETE FROM comment WHERE comment_id=" . $comment_id);
    if ($deletecomment) {
        $app->response()->header("Content-Type", "application/json");
        $response["id"] = $comment_id;
        $response["message"] = "Comment Deleted";
        echoResponse(200, $response);
    }
});