简体   繁体   English

在Facebook身份验证中使用Yii的HybridAuth重定向循环

[英]HybridAuth redirect loop with Yii in facebook authentication

I know there are many questions regarding this issue and because they didn't help me I'm asking new one. 我知道关于这个问题有很多问题,因为它们没有帮助我,所以我想问一个新问题。

Let me tell you how I've been trying to integrate. 让我告诉您我一直在尝试如何整合。 I've two actions in my controller actionIndex and actionDone . 我在我的控制器的actionIndexactionDone两个动作。

In the first action I try to authenticate user (if the is already authenticated I grab user information and save it into my database) and in the second action I just include hybrid index.php (to process hybridauth). 在第一个操作中,我尝试对用户进行身份验证(如果已经通过身份验证,则获取用户信息并将其保存到我的数据库中),在第二个操作中,我仅包含hybrid index.php(以处理hybridauth)。

And the most interesting thing I'm going to tell is that This work perfectly on localhost but not in live server 我要说的最有趣的是, 它可以在localhost上完美运行,但不能在实时服务器上运行

It is really annoying and wasted many hours. 这确实很烦人,浪费了很多时间。 here is code of both actions: 这是两个动作的代码:

$ha = $this->_getHA(); //i'm just bring files here
$adapter = $ha->authenticate('facebook');

if ($adapter->isUserConnected()) {

  // get user profile
  $profile = $adapter->getUserProfile();

  /*
   * If user has authenticated already
   */
  $social_id = (int) $profile->identifier;

  ....
  }
}

Second Action: 第二动作:

 public function actionDone() {

  $path = Yii::getPathOfAlias("ext.hybridauth.index") . '.php';
  require $path;


}

Note: I'am sure my base_url is correct. 注意:我确定我的base_url是正确的。

Thanks for helping in advance. 感谢您的提前帮助。

I also faced the Same problem many times . 我也多次遇到同样的问题。 Your Server base-path not configured correctly . 您的服务器基本路径配置不正确。 You just check this variable 您只需检查此变量

   $path = Yii::getPathOfAlias("ext.hybridauth.index") . '.php';

try to change by this way it may help 尝试通过这种方式进行更改可能会有所帮助

 $path = Yii::getPathOfAlias("ext.hybridauth") .'/index.php';

In your controllers you can then get the Hybrid_Auth object: 然后,您可以在控制器中获取Hybrid_Auth对象:

$ha = Yii::app()->getModule('hybridauth')->getHybridAuth();
$facebook = $ha->getAdapter('facebook');
$facebook->setUserStatus('Hi');

use this 用这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM