php sdk

This is the facebook php sdk. You can download it here: https:github.comfacebookfacebook-php-sdk

require 'facebook-php-sdksrcfacebook.php';

$facebook = new Facebook(array(
  'appId'  => 'YOUR_APP_ID',
  'secret' => 'YOUR_APP_SECRET',
));

 Get User ID
$user = $facebook->getUser();

if ($user) {
  try {
     Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}