title: Facebook SDK - Get access token programatically
body: <p>I have a web application made with PHP and when I submit a particular form, I want to publish to my Facebook fan page.
  You can see the below code:</p>
  
  <pre><code>    $appId = "...";
      $appSecret = "...";
      $version = "v2.5";
  
      $fb = new Facebook\Facebook([
          'app_id' =&gt; $appId,
          'app_secret' =&gt; $appSecret,
          'default_graph_version' =&gt; $version,
      ]);
  
      $accounts = $fb-&gt;get("/me/accounts");
      $pages = $accounts-&gt;getGraphEdge()-&gt;asArray();
  </code></pre>
  
  <p>With that code I have the  <code>FacebookSDKException</code> saying that <code>You must provide an access token.</code> 
  I have not found a way to generate the access token programatically just using <a href="https://developers.facebook.com/tools/explorer" rel="nofollow">https://developers.facebook.com/tools/explorer</a>.
  My composer:</p>
  
  <pre><code>"require": {
          "facebook/php-sdk-v4" : "~5.0"
  }
  </code></pre>
  
  <p>How can I get an access token programatically/automatically? Or what alternative do you suggest?</p>