title: Facebook Connect Fetching user Data
body: <p>I have followed the Facebook PHP SDK example and created the following.</p>
  
  <pre><code>&lt;?php
  
      require ("lib/facebook.php");
  
      $facebook = new Facebook(array('appId' =&gt; 'XXXXXXXXXXXX', 'secret' =&gt; 'XXXXXXXXXXXXXXXXXXXXXXX', 'cookie' =&gt; true, ));
  
      $session = $facebook-&gt;getSession();
      $me = null;
      // Session based API call.
      if($session) {
          try {
              $uid = $facebook-&gt;getUser();
              $me = $facebook-&gt;api('/me');
          }
          catch (FacebookApiException $e) {
              error_log($e);
          }
      }
  
      // login or logout url will be needed depending on current user state.
      if($me) {
          $logoutUrl = $facebook-&gt;getLogoutUrl();
      } else {
          $loginUrl = $facebook-&gt;getLoginUrl();
      }
      ?&gt;
  
      &lt;!doctype html&gt;
      &lt;html xmlns:fb="http://www.facebook.com/2008/fbml"&gt;
          &lt;head&gt;
          &lt;title&gt;php-sdk&lt;/title&gt;
          &lt;style&gt;
      body {
          font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
      }
      h1 a {
          text-decoration: none;
          color: #3b5998;
      }
      h1 a:hover {
          text-decoration: underline;
      }
      &lt;/style&gt;
          &lt;/head&gt;
  
          &lt;body&gt;
      &lt;div id="fb-root"&gt;&lt;/div&gt;
      &lt;script&gt;
            window.fbAsyncInit = function() {
              FB.init({
                appId   : '&lt;?php
      echo $facebook-&gt;getAppId();
      ?&gt;',
                session : &lt;?php
      echo json_encode($session);
      ?&gt;, // don't refetch the session when PHP already has it
                status  : true, // check login status
                cookie  : true, // enable cookies to allow the server to access the session
                xfbml   : true // parse XFBML
              });
  
              // whenever the user logs in, we refresh the page
              FB.Event.subscribe('auth.login', function() {
                window.location.reload();
              });
            };
  
            (function() {
              var e = document.createElement('script');
              e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
              e.async = true;
              document.getElementById('fb-root').appendChild(e);
            }());
          &lt;/script&gt;
      &lt;?php
      if($me):
      ?&gt;
      &lt;a href="&lt;?php
          echo $logoutUrl;
      ?&gt;"&gt; &lt;img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif"&gt; &lt;/a&gt;
      &lt;?php
      else:
      ?&gt;
      &lt;div&gt; Using JavaScript &amp;amp; XFBML:
            &lt;fb:login-button&gt;&lt;/fb:login-button&gt;
          &lt;/div&gt;
      &lt;?php
      endif;
      ?&gt;
      &lt;h3&gt;Session&lt;/h3&gt;
      &lt;?php
          if($me):
      ?&gt;
      &lt;pre&gt;&lt;?php
              print_r($session);
      ?&gt;&lt;/pre&gt;
      &lt;h3&gt;You&lt;/h3&gt;
      &lt;img src="https://graph.facebook.com/&lt;?php
              echo $uid;
      ?&gt;/picture"&gt; &lt;?php
              echo $me['name'];
      ?&gt;
      &lt;h3&gt;Your User Object&lt;/h3&gt;
      &lt;pre&gt;&lt;?php
              print_r($me);
      ?&gt;&lt;/pre&gt;
      &lt;?php
          else:
      ?&gt;
      &lt;strong&gt;&lt;em&gt;You are not Connected.&lt;/em&gt;&lt;/strong&gt;
      &lt;?php
          endif;
      ?&gt;
      &lt;?php
              print_r($me);
      ?&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>When i click Login. It opens the window and when i allow permission. It refreshes the window. only to show the same content. when i do a <code>print_r($me)</code> nothing is visible. </p>
  
  <p>When i check in the Application settings. The application has been installed in my fb account.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p><img src="https://i.stack.imgur.com/O8kiD.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/JrOP6.png" alt="enter image description here"></p>