Esempio n. 1
0
});
/**
 * Comment Registration
 * url - /comment
 * method - POST
 * params - place_id, comment
 * Return: id of the new added comment, or 400 if there are any error
 */
$app->post('/comment', function () use($app) {
    verifyRequiredParams(array('place_id', 'comment'));
    $response = array();
    // reading post params
    $place_id = $app->request->post('place_id');
    $comment = $app->request->post('comment');
    $db = new db_handler();
    $result = $db->addComment($place_id, $comment);
    if (!$result) {
        $response["error"] = true;
        $response["message"] = "Sorry, an error has occurred adding the comment";
        echoResponse(400, $response);
    } else {
        $response["error"] = false;
        $response["message"] = "Comment added successfully";
        $response["comment_id"] = $result;
        echoResponse(200, $response);
    }
});
/**
 * Listing last added places
 * url /lastAddedPlaces
 * method GET