get user profile

This method can call a Facebook Graph API method, an FQL query, or a (DEPRECATED) REST API method, depending on the parameters passed in. To call a Graph API method, pass in the path as the first parameter; to run FQL queries or REST APIs, pass in the array of parameters required for the API call, as described below.

 Remember to copy files from the SDK\'s src directory to a
 directory in your application on the server, such as php-sdk
require_once(\'php-sdkfacebook.php\');

$config = array(
  \'appId\' => \'YOUR_APP_ID\',
  \'secret\' => \'YOUR_APP_SECRET\',
);

$facebook = new Facebook($config);
$user_id = $facebook->getUser();
  
if($user_id) {
   We have a user ID, so probably a logged in user.
   If not, we\'ll get an exception, which we handle below.
  try {
    $user_profile = $facebook->api(\'me\',\'GET\');
    echo \"Name: \" . $user_profile[\'name\'];
  } catch(FacebookApiException $e) {
     If the user is logged out, you can have a 
     user ID even though the access token is invalid.
     In this case, we\'ll get an exception, so we\'ll
     just ask the user to login again here.
    $login_url = $facebook->getLoginUrl(); 
    echo \'Please login.\';
    error_log($e->getType());
    error_log($e->getMessage());
  }   
} else {
   No user, print a link for the user to login
  $login_url = $facebook->getLoginUrl();
  echo \'Please login.\';
}