Ejemplo n.º 1
0
 public function postTweetComment()
 {
     checkUnauthorizedAccess();
     $id = getIdFromURL();
     checkIntValueOfId($id);
     if (post('comment')) {
         $tweetid = $id;
         $username = $_SESSION['username'];
         $userid = UserRepository::getIdByUsername($username);
         $content = htmlentities(trim(post('comment')));
         $comment = new TweetComment();
         $comment->setTweetid($tweetid);
         $comment->setUserid($userid);
         $comment->setContent($content);
         try {
             TweetCommentRepository::postComment($comment);
             echo json_encode(['comment' => parseText($comment->getContent()), 'user' => $username]);
         } catch (\PDOException $e) {
             $e->getMessage();
         }
     }
 }