У нас проблема с аутентификацией в Facebook.Мы используем phalcon, и у нас есть процесс аутентификации с плагином php-sdk-v4.Когда мы пытаемся войти в систему, у нас возникает ошибка слишком большого числа перенаправлений.Наш веб-сайт https://app.wowego.com/register. некоторая помощь?
КОД: ФАЙЛ: AUTH.PHP
public function loginWithFacebook()
{
$di = $this->getDI();
$facebook = new FacebookConnector($di);
$facebookUser = $facebook->getUser();
if (!$facebookUser) {
$scope = [
'scope' => 'email,user_birthday,user_location',
];
return $this->response->redirect($facebook->getLoginUrl($scope), true);
}
try {
return $this->authenticateOrCreateFacebookUser($facebookUser);
} catch (\FacebookApiException $e) {
$di->logger->begin();
$di->logger->error($e->getMessage());
$di->logger->commit();
$facebookUser = null;
}
}
FACEBOOKCONNECTOR.PHP
public function __construct($di)
{
$this->di = $di;
$fbConfig = $di->get('config')->pup->connectors->facebook;
$protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))).'://';
$protocol="https://";
if (isset($fbConfig['route'])) {
$this->url = $protocol.$_SERVER['HTTP_HOST'].$fbConfig['route'];
} else {
$this->url = $protocol.$_SERVER['HTTP_HOST'].'/usercontrol/loginwithfacebook';
}
//echo $this->url;die();
FacebookSession::setDefaultApplication($fbConfig->appId, $fbConfig->secret);
}
public function getLoginUrl($scope = [])
{
$this->helper = new FacebookRedirectLoginHelper($this->url);
return $this->helper->getLoginUrl($scope);
}
/**
* Get facebook user details.
*
* @return unknown|bool
*/
public function getUser()
{
try {
$this->helper = new FacebookRedirectLoginHelper($this->url);
$this->fb_session = $this->helper->getSessionFromRedirect();
} catch (FacebookRequestException $ex) {
$this->di->get('flashSession')->error($ex->getMessage());
} catch (\Exception $ex) {
$this->di->get('flashSession')->error($ex->getMessage());
}
if ($this->fb_session) {
$request = new FacebookRequest($this->fb_session, 'GET', '/me?fields=id,first_name,last_name,email');
$response = $request->execute();
$fb_user = $response->getGraphObject()->asArray();
return $fb_user;
}
return false;
}
USERCONTROLLER.PHP
public function loginwithfacebookAction()
{
try {
//echo "dentro del try";
$this->view->disable();
$fopen = fopen('../logs/loginWithFacebook.log');
fwrite( $this->auth->loginWithFacebook() , $fopen );
fclose( $fopen );
return $this->auth->loginWithFacebook();
} catch(AuthException $e) {
$this->flash->error('There was an error connectiong to Facebook.');
}
}