title: fb_exchange_token parameter not specified
body: <p>I cannot find any documentation on this.</p>
  
  <p>Here is my code:</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  require_once __DIR__ . '/vendor/autoload.php';
  $fb = new Facebook\Facebook([
    'app_id' =&gt; '000000000000000',
    'app_secret' =&gt; '00000000000000000000000000000',
    'default_graph_version' =&gt; 'v2.6',
    'persistent_data_hander' =&gt; 'session'
  ]);
  $redirect = 'http://www.domain.com/loggedin.php';
  $helper = $fb-&gt;getRedirectLoginHelper();
  
  if (isset($_COOKIE['LOGIN'])){
    header("Location: http://www.domain.com/loggedin.php");
    die();
  }else{
          $permissions  = ['user_birthday, user_location'];
          $loginUrl = $helper-&gt;getLoginUrl($redirect,$permissions);
  
  ?&gt;
  
  &lt;a href="&lt;?php echo "".$loginUrl; } ?&gt;"&gt;&lt;img src="assets/img/fbloginbutton.png"&gt;&lt;/a&gt;
  </code></pre>
  
  <p><strong>loggedin.php</strong></p>
  
  <pre><code>&lt;?php
  
  //debug
  //debug
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);
  //debug
  //debug
  
  session_start();
  require_once __DIR__ . '/vendor/autoload.php';
  $fb = new Facebook\Facebook([
    'app_id' =&gt; '00000000000000000',
    'app_secret' =&gt; '000000000000000000000000000000000',
    'default_graph_version' =&gt; 'v2.6',
    'persistent_data_hander' =&gt; 'session'
  ]);
  $helper = $fb-&gt;getRedirectLoginHelper();
  
  if (isset($_SESSION['fb_a_token']))
  {
    $fb-&gt;setDefaultAccessToken($_SESSION['fb_a_token']);
  }
  else
  {
    try {
      $accessToken = $helper-&gt;getAccessToken();
      $oAuth2Client = $fb-&gt;getOAuth2Client();
      $longLivedAccessToken = $oAuth2Client-&gt;getLongLivedAccessToken($accessToken);
      $fb-&gt;setDefaultAccessToken($longLivedAccessToken);
      $_SESSION['fb_a_token'] = (string) $longLivedAccessToken;
    } catch(Facebook\Exceptions\FacebookResponseException $e) {
      // When Graph returns an error
      echo 'Graph returned an error: ' . $e-&gt;getMessage();
      //header("Location: http://www.domain.com");
      die();
    } catch(Facebook\Exceptions\FacebookSDKException $e) {
      // When validation fails or other local issues
      // echo 'Facebook SDK returned an error: ' . $e-&gt;getMessage();
      header("Location: http://www.domain.com");
      die();
    } catch(Exception $e){
      header("Location: http://www.domain.com");
      die();
    }
  }
  
  $accessToken = $_SESSION['fb_a_token'];
  $request_parm = '/me?fields=name,gender,age_range,birthday,location';
  try {
          $response = $fb-&gt;get($request_parm);
          $userNode = $response-&gt;getGraphUser();
  }catch(Facebook\Exceptions\FacebookResponseException $e) {
          // When Graph returns an error
          //echo 'Graph returned an error: ' . $e-&gt;getMessage();
          header("Location: http://www.domain.com");
          die();
  } catch(Facebook\Exceptions\FacebookSDKException $e) {
          // When validation fails or other local issues
          //echo 'Facebook SDK returned an error: ' . $e-&gt;getMessage();
          header("Location: http://www.domain.com");
          die();
  } catch(Exception $e){
          header("Location: http://www.domain.com");
          die();
  }
  
  setcookie('LOGIN', 'yes', time() + 9600);
  
  $image = 'https://graph.facebook.com/'.$userNode-&gt;getId().'/picture?width=200';
  
  $birthday = $userNode-&gt;getProperty('birthday');
  $year = (int) $birthday-&gt;format('Y');
  $curryear = (int) date("Y");
  $userage = $curryear - $year;
  
  $gender = $userNode-&gt;getProperty('gender');
  if ($gender == null) {
          $gender = "other";
  }
  
      ?&gt;
  
  &lt;h3&gt;First name: &lt;?php echo "".$userNode-&gt;getName();                     ?&gt;      &lt;/h3&gt;
                                          &lt;h3&gt;Age:        &lt;?php echo "".$userage;                                ?&gt;       &lt;/h3&gt;
                                          &lt;h3&gt;Gender:     &lt;?php echo "".$gender;                           ?&gt;     &lt;/h3&gt;
                                          &lt;h3&gt;Location:   &lt;?php echo "".$userNode-&gt;getProperty('location')['name'];          ?&gt;   &lt;/h3&gt;
  </code></pre>
  
  <p>I want to know what fb_exchange_token does and how to deal with it.</p>
  
  <p>Replacting my error:</p>
  
  <ol>
  <li>delete all cache</li>
  <li>login and get redirected successfully</li>
  <li>close browser without deleting cache</li>
  <li>open browser again at loggedin.php and get this error: <strong>Graph returned an error: fb_exchange_token parameter not specified</strong> which is fired from the very first try-catch in loggedin.php. </li>
  </ol>
  
  <p>Due to shoddy documentation I cannot find anything on fb_exchange_token on the Facebook's website nor elsewhere.</p>
  
  <p>Can anyone help?</p>