title: making api calls on facebook login demo code
body: <p>i've started dabbling with the facebook login demo code and i was just wondering how to extract individual information from my code such as display pic, name, first-name, last-name, username and henceforth.</p>
  
  <p>currently the demo shows this:</p>
  
  <pre><code>Your User Object (/me)
  
      Array
      (
          [id] =&gt; 647445630
          [name] =&gt; John Molanza
          [first_name] =&gt; John
          [last_name] =&gt; Molanza
          [link] =&gt; http://www.facebook.com/johnmolanza
          [username] =&gt; johnmolanza
          [gender] =&gt; male
          [timezone] =&gt; 1
          [locale] =&gt; en_GB
          [verified] =&gt; 1
          [updated_time] =&gt; 2011-05-24T03:12:09+0000
      )
  </code></pre>
  
  <p>alongside my display picture and other things. but how do you display each piece of information individually for example [last_name] or [first_name] instead of everything at once.</p>
  
  <p>here is the code i am using below - thanking you in advance!</p>
  
  <blockquote>
    <p>
  
  <pre><code>//config
  include "resources/Connections/kite.php";
  
  require 'resources/facebook/src/facebook.php';
  
  $facebook = new Facebook(array(
    'appId'  =&gt; $appid_kite,
    'secret' =&gt; $secret_kite,
  ));
  
  // Get User ID
  $user = $facebook-&gt;getUser();
  
  // We may or may not have this data based on whether the user is
  </code></pre>
    
    <p>logged in.
        //
        // If we have a $user id here, it means we know the user is logged into
        // Facebook, but we don't know if the access token is valid. An access
        // token is invalid if the user logged out of Facebook.</p>
  
  <pre><code>if ($user) {
    try {
      // Proceed knowing you have a logged in user who's authenticated.
      $user_profile = $facebook-&gt;api('/me');
    } catch (FacebookApiException $e) {
      error_log($e);
      $user = null;
    }
  }
  
  // Login or logout url will be needed depending on current user
  </code></pre>
    
    <p>state.
        if ($user) {
          $logoutUrl = $facebook->getLogoutUrl();
        } else {
          $loginUrl = $facebook->getLoginUrl();
        }
        // This call will always work since we are fetching public data.
        $naitik = $facebook->api('/naitik');</p>
  
  <pre><code>?&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;h1&gt;php-sdk&lt;/h1&gt;
  
      &lt;?php if ($user): ?&gt;
        &lt;a href="&lt;?php echo $logoutUrl; ?&gt;"&gt;Logout&lt;/a&gt;
      &lt;?php else: ?&gt;
        &lt;div&gt;
          Login using OAuth 2.0 handled by the PHP SDK:
          &lt;a href="&lt;?php echo $loginUrl; ?&gt;"&gt;Login with Facebook&lt;/a&gt;
        &lt;/div&gt;
      &lt;?php endif ?&gt;
  
      &lt;h3&gt;PHP Session&lt;/h3&gt;
      &lt;pre&gt;&lt;?php print_r($_SESSION); ?&gt;&lt;/pre&gt;
  
      &lt;?php if ($user): ?&gt;
        &lt;h3&gt;You&lt;/h3&gt;
        &lt;img src="https://graph.facebook.com/&lt;?php
  </code></pre>
    
    <p>echo $user; ?>/picture"></p>
  
  <pre><code>      &lt;h3&gt;Your User Object (/me)&lt;/h3&gt;
        &lt;pre&gt;&lt;?php print_r($user_profile); ?&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;h3&gt;Public profile of Naitik&lt;/h3&gt;
      &lt;img src="https://graph.facebook.com/naitik/picture"&gt;
      &lt;?php echo $naitik['name']; ?&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  </blockquote>