title: Facebook SDK returned an error: You must provide an access token. Php Facebook Api
body: <pre><code>&lt;?php
  
  require_once 'Facebook/autoload.php';
  require_once 'Facebook/Authentication/AccessToken.php';
  $fb = new Facebook\Facebook([
    'app_id' =&gt; '2452542542fsrgrgrg',
    'app_secret' =&gt; '5245dffhdhr5535353535',
    'default_graph_version' =&gt; 'v2.2',
    ]);
  
  $linkData = [
    'link' =&gt; 'http://www.example.com',
    'message' =&gt; 'User provided message',
    ];
  $helper = $fb-&gt;getRedirectLoginHelper(); 
  try {
    $accessToken = $helper-&gt;getAccessToken(); 
    // Returns a `Facebook\FacebookResponse` object
    $response = $fb-&gt;post('/me/feed', $linkData, $accessToken);
  } catch(Facebook\Exceptions\FacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e-&gt;getMessage();
    exit;
  } catch(Facebook\Exceptions\FacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e-&gt;getMessage();
    exit;
  }
  
  $graphNode = $response-&gt;getGraphNode();
  
  echo 'Posted with id: ' . $graphNode['id'];
  
  ?&gt;
  </code></pre>
  
  <p>I am getting this error "Facebook SDK returned an error: You must provide an access token." I have tried to search around and I haven't got any reliable answers. Anyone who has an idea can share.</p>