title: Facebook Graph API PHP SDK v4 - Post on Page
body: <p>I wanna give all my website authors a possiblity to post their articles on our facebook page without having go give them admin access to it.</p>
  
  <p>So i created a simple form, where the author types in: URL, URL to image, message</p>
  
  <p>On submit, this form will send a ajax request to facebook.php where the magic "should" happen.</p>
  
  <p>The first problem occurs at "require_once".
  It's not possible to require all 4 files without having an error.
  If i get rid of the facebook exception, then everything works except the request itself. 
  There seems to be an PHP Error, because i get no ajax response at all.</p>
  
  <pre><code>session_start();
  
  require_once($_SERVER['DOCUMENT_ROOT'].'/sys/facebook/FacebookSession.php');
  require_once($_SERVER['DOCUMENT_ROOT'].'/sys/facebook/FacebookRequest.php');
  require_once($_SERVER['DOCUMENT_ROOT'].'/sys/facebook/GraphObject.php');
  require_once($_SERVER['DOCUMENT_ROOT'].'/sys/facebook/FacebookRequestException.php');
  
  use Facebook\FacebookSession;
  use Facebook\FacebookRequest;
  use Facebook\GraphObject;
  use Facebook\FacebookRequestException;
  
  $message = safe($_POST["message"]);
  $url = safe($_POST["url"]);
  $image = safe($_POST["image"]);
  
  if($message == "" OR $url == "" OR $image == ""){
      echo "incomplete";
      return;
  }
  
  FacebookSession::setDefaultApplication('{APP ID}','{APP SECRET}');
  $session = new FacebookSession('{Page Access Token}');
  
  if($session) {
      try {
          $response = (new FacebookRequest(
              $session, 'POST', '/{Page ID}/feed', array(
                  'message'       =&gt; $message,
                  'link'          =&gt; $url,
                  'picture'       =&gt; $image
              )
          ))-&gt;execute()-&gt;getGraphObject();
          echo "Posted with id: " . $response-&gt;getProperty('id');
      } catch(FacebookRequestException $e) {
          echo "Exception occured, code: " . $e-&gt;getCode();
          echo " with message: " . $e-&gt;getMessage();
      }
  } else {
      echo "No Session available!";
  }
  </code></pre>