title: How do I get Facebook Application Login to work
body: <p>I just started making an application for Facebook, however I ran into problem early on. The first step I want people to do is to give permission to access their profile. All over the web are examples of how to do this with:</p>
  
  <pre><code>$user_id = $facebook-&gt;require_login();
  </code></pre>
  
  <p>However, this is the way it works using the Old PHP API. I have downloaded and installed the new one in my application folder and it is not working anymore. </p>
  
  <p><strong>My question is (and i really have been searching for an answer for a long time) what is the code to do this with the new API?</strong> </p>
  
  <p>(and related question: is it better to use the old API, or learn to work with the new one when I am just starting making apps right now)</p>
  
  <p>I have this code now;</p>
  
  <pre><code>    &lt;?php
          // Awesome Facebook Application
          //
          // Name: -
          //
  
          require_once 'facebook-php-sdk/src/facebook.php';
          $app_id = "-";
  $app_secret = "-";
  
          // Create our Application instance.
  $facebook = new Facebook(array(
          'appId' =&gt; $app_id,
          'secret' =&gt; $app_secret,
          'cookie' =&gt; true
  ));
  
  $session = $facebook-&gt;getSession();
  $loginUrl = $facebook-&gt;getLoginUrl(
          array(
          'canvas'    =&gt; 1,
          'fbconnect' =&gt; 0,
          'req_perms' =&gt; 'email,publish_stream,status_update,user_birthday, user_location,user_work_history'
          )
  );
  
  $fbme = null;
  
  if (!$session) {
      echo "&lt;script type='text/javascript'&gt;top.location.href = '$loginUrl';&lt;/script&gt;";
      exit;
  }
  else {
      try {
          $uid      =   $facebook-&gt;getUser();
          $fbme     =   $facebook-&gt;api('/me');
  
      } catch (FacebookApiException $e) {
          echo "&lt;script type='text/javascript'&gt;top.location.href = '$loginUrl';&lt;/script&gt;";
          exit;
      }
  }
  
  
  echo "&lt;p&gt;hello, &lt;fb:name uid=\"$user_id\" useyou=\"false\" /&gt;!&lt;/p&gt;";
  
  
  ?&gt;
  </code></pre>