title: Facebook scope PHP
body: <p>I'm trying to work with Facebook's default PHP website integration and authentication.
  When a user logs in, I'm able to request permissions to get various information from the user.</p>
  
  <hr>
  
  <blockquote>
    <p><strong>This question is kind of old. Please take note of harkirat1892's comment.</strong></p>
    
    <p>"If someone using Facebook SDK v4.4 is stumbling across this question, the answer by Dhiraj won't >work in that case as there is a small change. You don't have to include redirect_uri in the array >passed to getLoginUrl.</p>
    
    <p>As per v4.4, getLoginUrl should work like:</p>
  </blockquote>
  
  <pre><code>$loginUrl = $facebook-&gt;getLoginUrl(
  array(
      'scope'         =&gt; 'email,user_checkins, user_birthday'
  )
  );
  </code></pre>
  
  <blockquote>
    <p>The various scopes can be found here: <a href="https://developers.facebook.com/docs/facebook-login/permissions#referencehttps://developers.facebook.com/docs/facebook-login/permissions#reference" rel="nofollow noreferrer">Facebook permissions</a>."</p>
  </blockquote>
  
  <hr>
  
  <p>It was really easy to figure out how to do it with the JavaScript one, but I'm confused where to specify the scope in the PHP example.</p>
  
  <p>Basically, I just want to request for permission to access their email &amp; location and maybe some other information.</p>
  
  <p>Here is the code I'm working with:
  (It's modified slightly, but it is almost an exact match to what they had.)</p>
  
  <pre><code>&lt;?php
      define('YOUR_APP_ID', '---------');
      define('YOUR_APP_SECRET', '------------');
  
      //Uses the PHP SDK.  Download from https://github.com/facebook/php-sdk
      require 'facebook.php';
  
      $facebook = new Facebook(array(
        'appId'  =&gt; YOUR_APP_ID,
        'secret' =&gt; YOUR_APP_SECRET,
      ));
  
      $FBUID = $facebook-&gt;getUser();
  ?&gt;
  
  &lt;?php  if ($FBUID) {
      $userInfo = $facebook-&gt;api('/' + $FBUID); ?&gt;
  
  &lt;?php $FBName = $userInfo['name'];?&gt;
      &lt;!--
        Welcome &lt;? // = $userInfo['name'] ?&gt; --&gt;
  
  &lt;?php } else { ?&gt;
      &lt;div id="fb-root"&gt;&lt;/div&gt;
      &lt;fb:login-button&gt;&lt;/fb:login-button&gt;
  &lt;?php } ?&gt;
  
      &lt;script&gt;
          window.fbAsyncInit = function() {
              FB.init({
                  appId      : '---------------',
                  status     : true,
                  cookie     : true,
                  xfbml      : true,
                  oauth      : true,
              });
  
              FB.Event.subscribe('auth.login', function(response) {
                  window.location.reload();
              });
          };
  
          (function(d){
              var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
              js = d.createElement('script'); js.id = id; js.async = true;
              js.src = "//connect.facebook.net/en_US/all.js";
              d.getElementsByTagName('head')[0].appendChild(js);
           }(document));
      &lt;/script&gt;
  </code></pre>