title: Facebook PHP API post to wall falls under "Recent Posts by Others"
body: <p>I want to post a message to the wall of a Facebook Page. I am the admin of the app and the page used in this code, I already gave permissions needed for my app to be able to post on my page, it works when I use only the field "message", like this:</p>
  
  <pre><code>$message = array(
              'message' =&gt; "Test2",&lt;br&gt;
             );
  $result = $fb-&gt;api('/411895472189524/feed','POST',$message);
  </code></pre>
  
  <p>The code above posts to my page wall and the post is made "from" the page itself, just like if I would do it manually from facebook. This is working great.</p>
  
  <p><strong>But when I try to add more fields</strong> like "link" or "picture" or "description" the post goes in the "Recent Posts by Others on TEST Jojo Page" and the post is now made from my personnal account (Joelle Landrie) instead of from the page itself. See code below.</p>
  
  <pre><code>$message = array(
              'message' =&gt; "Test2",
              'picture' =&gt; "http://www.cleanpopo.com/uploads/1/3/1/5/13154615/245431315.jpg",
              'description' =&gt; "This is a test description",
              'link' =&gt; "google.com"
             );
  $result = $fb-&gt;api('/411895472189524/feed','POST',$message);
  </code></pre>
  
  <p>See: <a href="https://www.facebook.com/pages/TEST-Jojo-Page/411895472189524">https://www.facebook.com/pages/TEST-Jojo-Page/411895472189524</a></p>
  
  <p>The <code>link</code> field seems to be causing problem, I can get a successful post on my page using the <code>message</code>, <code>picture</code> and <code>description</code> field. Only this is useless to me, I need my post to have a link.</p>
  
  <p><br><br></p>
  
  <h1>SOLUTION</h1>
  
  <p>Thanks to Shadowfax who asked if I was using the "page_access_token". I was not. I started looking on the web how to get this token, added it to my code and now it works great!!</p>
  
  <h3>The Final Code</h3>
  
  <pre><code>$appId = 'YOUR APP ID';
  $secret = 'YOUR SECRET';
  $returnurl = 'http://www.yoursite.com';
  $permissions = 'manage_pages, publish_stream, offline_access';
  
  $fb = new Facebook(array('appId'=&gt;$appId, 'secret'=&gt;$secret));
  $fbuser = $fb-&gt;getUser();
  
  if($fbuser){
  
          $page_id = "YOUR PAGE ID";
          $page_access_token = "";
          $result =  $fb-&gt;api("/me/accounts");
  
          // loop trough all your pages and find the right one
          if( !empty($result['data']) )
          {
             foreach($result["data"] as $page) 
             {
               if($page["id"] == $page_id)
               {
                 $page_access_token = $page["access_token"];
                 break;
               }
             }
          }
          else
          {
            echo "AN ERROR OCCURED: could not get the access_token. Please verify the page ID ".$page_id." exists.";
          }
  
          // set the facebook active facebook access token as the one we just fetch
          $fb-&gt;setAccessToken($page_access_token);
  
          // Now try to post on page's wall
          try{
              $message = array(
                  'message' =&gt; "YOUR MESSAGE",
                  'picture' =&gt; "YOUR PICTURE",
                  'description' =&gt; "YOUR DESCRIPTION",
                  'link' =&gt; "YOUR LINK"
              );
              $result = $fb-&gt;api('/'.$page_id.'/feed','POST',$message);
              if($result){
                  echo 'Successfully posted to Facebook Wall...';
              }
          }catch(FacebookApiException $e){
              echo $e-&gt;getMessage();
          }
  
      }else{
  
          $fbloginurl = $fb-&gt;getLoginUrl(array('redirect-uri'=&gt;$returnurl, 'scope'=&gt;$permissions));
          echo '&lt;a href="'.$fbloginurl.'"&gt;Login with Facebook&lt;/a&gt;';
  
      }
  </code></pre>