title: How do you pass multiple scope parameters through a Facebook PHP SDK to execute queries that require permissions?
body: <p>I have a current 3-page web site/app to pull/display data from Facebook using my PHP SDK code, I'm getting the error:</p>
  
  <blockquote>
    <p>The redirect_uri URL must be absolute</p>
  </blockquote>
  
  <p>This is because of this code below: </p>
  
  <pre><code>$params = array(
         'scope' =&gt; 'ads_management',
         'redirect_uri' =&gt; 'http://example.com/login-callback.php',
      );
  $loginUrl = $helper-&gt;getLoginUrl($params);
  </code></pre>
  
  <p>Before changing it to this, I didn't have this ^ at all, and just this line instead:</p>
  
  <pre><code>$loginUrl = $helper-&gt;getLoginUrl('http://example.com/login-callback.php');
  </code></pre>
  
  <p>If I were to query posts and stuff that didn't require permissions, things worked smoothly. But I need to do queries like the ones below, located in <code>fb-stats.php</code>. I guess the way I have the params is wrong, but I don't exactly know the right way to format it.</p>
  
  <p>Here's <code>fb.php</code>:</p>
  
  <pre><code>&lt;?php
      session_start();
      require_once '../vendor/autoload.php';
  
      // Checks if token is set and redirects to another page.
      if (isset($_SESSION['facebook_access_token'])) {
          // Logged in!
  
          header('Location: fb-stats.php'); exit();
      }
  
      $fb = new Facebook\Facebook([
          'app_id' =&gt; 'MYAPPID',
          'app_secret' =&gt; 'MYAPPSECRET',
          'default_graph_version' =&gt; 'v2.5',
      ]);
  
      $helper = $fb-&gt;getRedirectLoginHelper();
  
      // The site below is 'example' is actually my live site.
      $params = array(
              'scope' =&gt; 'ads_management',
              'redirect_uri' =&gt; 'http://example.com/login-callback.php',
          );
  
      $loginUrl = $helper-&gt;getLoginUrl($params);
  
      echo '&lt;a href="' . $loginUrl . '"&gt;Log in with Facebook!&lt;/a&gt;';
  ?&gt;
  </code></pre>
  
  <p>Here's <code>login-callback.php</code>:</p>
  
  <pre><code>&lt;?php
      session_start();
      require_once '../vendor/autoload.php';
      $fb = new Facebook\Facebook([
          'app_id' =&gt; 'MYAPPID',
          'app_secret' =&gt; 'MYAPPSECRET',
          'default_graph_version' =&gt; 'v2.5',
      ]);
  
  
      $helper = $fb-&gt;getRedirectLoginHelper();
      try {
          $accessToken = $helper-&gt;getAccessToken();
      }
      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;
      }
  
      if (isset($accessToken)) {
          if (! $accessToken-&gt;isLongLived()) {
              try {
                  $accessToken = $oAuth2Client-&gt;getLongLivedAccessToken($accessToken);
              }
              catch (Facebook\Exceptions\FacebookSDKException $e) {
                  echo "&lt;p&gt;Error getting long-lived access token: " . $helper-&gt;getMessage() . "&lt;/p&gt;\n\n";
                  exit;
              }
          }
  
          header('Location: fb-stats.php'); exit();
      }
  </code></pre>
  
  <p>Here's <code>fb-stats.php</code>:</p>
  
  <pre><code>&lt;?php
      session_start();
      require_once '../vendor/autoload.php';
  
      $fb = new Facebook\Facebook([
          'app_id' =&gt; 'MYAPPID',
          'app_secret' =&gt; 'MYAPPSECRET',
          'default_graph_version' =&gt; 'v2.5',
      ]);
  
      $fb-&gt;setDefaultAccessToken('access-token');
  
      try {
          $response = $fb-&gt;get('/PAGEID/insights/page_impressions?period=day', '{access token}');
          $insightsNode = $response-&gt;getGraphEdge();
      }
      catch(Facebook\Exceptions\FacebookResponseException $e) {
          // When Graph returns an error
          echo 'Graph returned an error: ' . $e-&gt;getMessage();
          exit;
      }
      catch(Facebook\Exceptions\FacebookSDKException $e) {
          // When validation fails or other local issues
          echo 'Facebook SDK returned an error: ' . $e-&gt;getMessage();
          exit;
      }
  
      var_dump($insightsNode);
  </code></pre>
  
  <p>The query I'm trying to execute needs permissions of <code>ads_management</code> and <code>read_insights</code> but I'm confused as to how to get mutltiple scopes going aside from the error I'm currently getting for the <code>redirect_uri</code> not being absolute. How would I go about fixing these things?</p>