Example #1
0
 }
 if (!is_null($session)) {
     // Get fb information
     $userProfile = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className());
     $fbName = $userProfile->getName();
     $fbId = $userProfile->getId();
     // Get account from database
     $db = DP::getInstant();
     $accountSrv = new AccountService($db);
     $account = $accountSrv->getByFbId($fbId);
     // Insert into database If account not exist
     if (is_null($account)) {
         $account = new Account();
         $account->fbId = $fbId;
         $account->fbName = $fbName;
         $accountSrv->insert($account);
     }
     $_SESSION[FB_TOKEN] = $session->getToken();
     $_SESSION[FB_UID] = $fbId;
 }
 // Redirect to specified page
 if (isset($_SESSION['PREV_URL1'])) {
     $url = $_SESSION['PREV_URL1'];
     $_SESSION['PREV_URL1'] = null;
     Flight::redirect($url);
 }
 if (isset($_SESSION['PREV_URL'])) {
     Flight::redirect($_SESSION['PREV_URL']);
 } else {
     Flight::redirect('/');
 }