title: Facebook Graph API PHP SDK posting on page as page
body: <p>It's final try with PHP, if it fails, I'll try with JS. So my goal is to post on FB page as "Page name" through PHP: this is what I want to get</p>
  
  <p><img src="https://i.stack.imgur.com/9JPjX.png" alt="View 1"></p>
  
  <p>But all I get is shown pic below. Also, it's visible ONLY to this profile (not to friends/ppl who like/etc.). </p>
  
  <p><img src="https://i.stack.imgur.com/MvGzg.png" alt="View 2"></p>
  
  <p>This is my current code</p>
  
  <pre><code>function post_facebook($data=null, $redir = null){
          $result = "";
          require_once (ROOT. "/apps/configuration/models/ConfigurationItem.php");
          require_once (ROOT . "/components/facebook/facebook.php");
  
          $this-&gt;ConfigurationItem = new ConfigurationItem($this-&gt;getContext());
  
          $row=$this-&gt;ConfigurationItem-&gt;findByCatKeyItemKey('system','facebook_login');
          $apiid=$row['value']; &lt;= Correct apiid
  
          $row=$this-&gt;ConfigurationItem-&gt;findByCatKeyItemKey('system','facebook_pass');
          $secret=$row['value']; &lt;= Correct secret key
  
          $facebook = new Facebook(array(
            'appId'  =&gt; $apiid,
            'secret' =&gt; $secret,
            'cookie' =&gt; true,
          ));
  
          $session = $facebook-&gt;getSession();
          $me = null;
          if ($session) {
              try {
                  $uid = $facebook-&gt;getUser();
                  $me = $facebook-&gt;api('/me');
              } catch (FacebookApiException $e) {
                  error_log($e);
              }
              $message=$data['facebook_text'];
              $attachment = array(
                  'message' =&gt; $data['facebook_text'],
                  'name' =&gt; $data['name'],
                  'link' =&gt; $this-&gt;getLinkToLatestNews(),
                  'description' =&gt; '',
              );
  
              try {
                  $facebook-&gt;api('/PAGE ID/feed/', 'post', $attachment);
                  $result = "Facebook: Sent";
              } catch (FacebookApiException $e) {
                  $result = "Facebook: Failed";
                  error_log($e);
              }
          } else {
              $login_url = $facebook-&gt;getLoginUrl();
              header("Location: ".$login_url);
              exit;
          }
  
          echo $result;
          exit;
          //return $result;
  
      }
  </code></pre>
  
  <p>What I'm doing wrong? I couldn't find anything in API documentation/top google results, only for JS. Thanks for help!</p>