<?php
require_once __DIR__ . '/facebook-php-sdk/autoload.php';

use Facebook\Facebook;
use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;

$appId          = '261179448080846';
$appSecret      = 'b1e07cb3e613cc61d5248ad0691d4b14';
$settings['ssl'] ? $base = 'https' : $base = 'http';
$redirectURL    = $base . "://" . $_SERVER['SERVER_NAME'] . '/globelus-login.php?f_type=0&f_register=0';
$fbPermissions 	= array('email');

$fb = new Facebook(array(
	'app_id'                => $appId,
	'app_secret'            => $appSecret,
	'default_graph_version' => 'v2.10'
));

$helper = $fb -> getRedirectLoginHelper();

if ( !$_GET['scope'] )
{
  if ( isset( $_SESSION['facebook_access_token'] ) )
    $accessToken = $_SESSION['facebook_access_token'];
  else
    $accessToken = $helper -> getAccessToken();
}