Rubenwouters\CrmLauncher\ApiCalls\FetchFacebookContent::answerPost PHP Method

answerPost() public method

Answer to Facebook post
public answerPost ( string $answer, integer $messageId ) : array | Illuminate\View\View
$answer string
$messageId integer
return array | Illuminate\View\View
    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();
        }
    }

Usage Example

 /**
  * 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();
 }
All Usage Examples Of Rubenwouters\CrmLauncher\ApiCalls\FetchFacebookContent::answerPost