Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function comment(Post $post, $comment)
 {
     // Get post user
     $postUser = $post->getUser();
     // Check comment not empty
     if (empty($comment)) {
         throw new \Exception('Comment invalid - cannot be empty');
     }
     // Check comment contains @mention
     if (strpos($comment, '@' . $postUser->getHandle()) === false) {
         // Invalid comment
         throw new \Exception('Comment invalid - must @mention original post user');
     }
     // Get library service
     $libService = $this->getLibService();
     // Build request url
     $postData = array('status' => $comment, 'in_reply_to_status_id' => $post->getId());
     $requestUrl = 'statuses/update.json?' . http_build_query($postData);
     // Call api
     try {
         $response = new Response($libService->request($requestUrl, 'POST'));
     } catch (\Exception $e) {
         $this->propogateException($e);
     }
     return $response;
 }