title: How to post to a Facebook Page (how to get page access token + user access token)
body: <p>I am trying to work out how to post to a Facebook page wall, when using my app as a different Facebook User (who is not the Page Administrator).</p>
  
  <p>I get a range of error messages while testing:
  Exception: 200: The user hasn't authorized the application to perform this action</p>
  
  <p>The page administrator has visited the app and accepted the following permissions: publish_stream, manage_pages, offline_access</p>
  
  <p>Here is the code I plan to use:</p>
  
  <pre><code>// Insert Page Administrators ID here 
  // This user is not the same user that is currently logged in and using the app
  // This user is the page administrator who has authorised: 
  // - manage_pages
  // - offline_access
  // - publish_stream
  
  $user_id = '123456789'; 
  
  // Insert Page ID here
  $page_id = '123456789'; 
  
  $accounts = $facebook-&gt;api('/'.$user_id.'/accounts');
  
  foreach($accounts['data'] as $account)
  {
    if($account['id'] == $page_id)
    {
      $page_access_token = $account['access_token'];
      echo "&lt;p&gt;Page Access Token: $page_access_token&lt;/p&gt;";
    }
  }
  
  // publish to the wall on your page
  try
  {
    $result = $facebook-&gt;api(array( "uid" =&gt; $page_id, 
                                    "method" =&gt; "stream.publish",
                                    "access_token" =&gt; $page_access_token,
                                    "message" =&gt; $message, ));
  }
  catch (FacebookApiException $e)
  {
    error_log('FB Error: Could not post on Page Wall. Page ID: ' . $page_id);
    error_log('FB Error Message: ' . $e);
  }
  </code></pre>
  
  <p>Note: There may be PHP errors in the code above, as I just spliced it on the fly, but its not so much the PHP errors I need correcting, but more my logically understanding of how I am meant to go about this process.</p>
  
  <p>PROBLEM: 
  I can't access the $user_id/accounts information without an active user access token for the Page Administrator. </p>
  
  <p>The end result that I'm trying to achieve is:
  1.) A normal FB user goes to the app and submits a form
  2.) The app posts a message on a FB Page wall, which is not owned by the FB user, but has previously been authorized by the Page Administrator with the following permissions manage_pages, publish_stream and offline_access</p>
  
  <p>Q1. Since the Page Administrator has accepted the appropriate permissions, why can't I just generate an active user access token, without the actual Page Administrator user logging into the website?</p>
  
  <p>Q2. Is there a way I can get the equivalent of /$user_id/accounts for the Page Administrator user_id, when logged into Facebook as a different user (which is why I do not use /me/accounts)?</p>
  
  <p>Q3. Please confirm that my understanding of needing the page access token to post to the page wall is correct (or do I need the user access_token for the Page Administrator - see Q1)?</p>
  
  <p>Q4. Anyone have a handy resource on what each type of access_token can actually access?</p>
  
  <p>If you need any more information, please let me know.
  I've spent the last few days working on this and I'm stuck.</p>
  
  <p>Thanks!</p>