public function answerPost($answer, $messageId) { $fb = initFb(); $token = $this->config->FbAccessToken(); try { $reply = $fb->post('/' . $messageId . '/comments?message=' . rawurlencode($answer), array('access_token' => $token)); Session::flash('flash_success', trans('crm-launcher::success.post_sent')); return json_decode($reply->getBody()); } catch (Exception $e) { getErrorMessage($e->getCode()); return back(); } }
/** * Reply post (Facebook) * * @param Request $request * @param integer $id * * @return view */ public function replyPost(Request $request, $id) { $this->validate($request, ['answer' => 'required']); $publishment = $this->publishment->find($id); if ($request->input('in_reply_to') != "") { $replyTo = $request->input('in_reply_to'); $reply = $this->facebookContent->answerPost($request->input('answer'), $replyTo); $this->insertInnerComment($id, $request, $replyTo, $reply); } else { $replyTo = $publishment->fb_post_id; $reply = $this->facebookContent->answerPost($request->input('answer'), $replyTo); $this->reaction->insertReaction(self::TYPE_FACEBOOK, $reply, $id, $request->input('answer')); } return back(); }