title: Facebook api how to get userid and name?
body: <p>I am using facebook php api for fetching data. Please help me on how to authenticate and fetch userid, name, email, gender.(I HAVE asked for email permission).</p>
  
  <p>Here is my code:</p>
  
  <pre><code>require 'facebookcredentials.php';
  require 'facebookapi.php';
  $facebook = new Facebook(array(
    'appId'  =&gt; $app_id,
    'secret' =&gt; $secret,
    'cookie' =&gt; true,
  ));
  
       $facebook-&gt;getLoginUrl(array('req_perms' =&gt; 
      'email,read_stream,publish_stream,create_event,rsvp_event'));
  </code></pre>
  
  <p>Please tell me how to first authenticate the user and then get <code>$userid, $name, $gender, $email</code></p>