/** * * @param Request $request * @param Response $response * @param array $args */ public function callback(Request $request, Response $response, $args) { // cleanup the session $this->session->clear(); if ($this->facebook->getAccessToken()) { return $response->withRedirect($this->router->pathFor('home')); } return $response->withRedirect($this->router->pathFor('login')); }
/** * * @param unknown $response * @return boolean */ public function captateUser() { if ($this->facebook->hasAccessToken()) { $this->logger->debug('user has access token : ' . $this->facebook->getAccessToken()); try { $this->logger->debug('facebook load data'); // load and store profile. $profile = $this->facebook->retriveProfile(); // geolocate and store the ip $location = $this->facebook->retriveLocationFromIp(); if ($location) { $this->facebook->storeLocationInProfile($location); } else { $this->logger->error('Unable to geolocate user'); } return true; } catch (\Exception $ex) { $this->logger->error($_SERVER['HTTP_USER_AGENT'] . ' - ' . $ex->getMessage()); return false; } } }