简体   繁体   English

登录 facebook 错误:ERR_TOO_MANY_REDIRECTS

[英]Login with facebook error: ERR_TOO_MANY_REDIRECTS

I am trying to login with facebook but i am getting too many redirect error.我正在尝试使用 facebook 登录,但我收到太多重定向错误。 Please help me how to fix it.请帮助我如何修复它。

I have tried Browser cookie clear does not work.我试过浏览器 cookie 清除不起作用。

<?php
require 'facebook/facebook.php';
require 'config/fbconfig.php';
require 'config/functions.php';

$facebook = new Facebook(array(
            'appId' => APP_ID,
            'secret' => APP_SECRET,
            ));

$user = $facebook->getUser();

// I think i am not getting user. So i get 0 in user.
if ($user) {

  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }

    if (!empty($user_profile )) {
        # User info ok? Let's print it (Here we will be adding the login and registering routines)
        $username = $user_profile['name'];
        $uid = $user_profile['id'];
        $email = $user_profile['email'];
        $user = new User();

                $img = file_get_contents('https://graph.facebook.com/'.$user_profile['id'].'/picture?type=large');
                $file = $_SESSION['SITE_IMG_PATH'].'userimage/'.$user_profile['id'].'.jpg';
                file_put_contents($file, $img);
                $userimage=$user_profile['id'].'.jpg';
        $userdata = $user->checkUser($uid, 'facebook', $username,$email,$twitter_otoken,$twitter_otoken_secret,$userimage);

        if(!empty($userdata)){
            session_start();
            $_SESSION['frontuser_info'] = $userdata;

            $Qparam=$fid.''.$sid.''.$tid;

            header("Location: ".$_SESSION['APP_PATH']."".$Qparam);

        }
    } else {
        # For testing purposes, if there was an error, let's kill the script
        die("There was an error.");
    }
} else {

    # There's no active session, let's generate one

    $login_url = $facebook->getLoginUrl(array( 'scope' => 'email'));

    # i think it is always coming here thats error.
    header("Location: " . $login_url);
}

?>

Please see code and help me to fix this redirection error i am always going in else part thats error.请查看代码并帮助我修复此重定向错误,我总是在其他部分出错。

登录 facebook 错误:ERR_TOO_MANY_REDIRECTS

There seems to be some issue with your Facebook Plugin , that's why $user coming as 0. There can be many other reason behind it too.您的Facebook Plugin似乎存在一些问题,这就是$user为 0 的原因。这背后也可能有许多其他原因。 You need to re-check your APP_ID and APP_SECRET as well.您还需要重新检查您的APP_IDAPP_SECRET

Most importantly, you need to follow below links and update accordingly.最重要的是,您需要按照以下链接进行相应更新。

https://github.com/facebook/php-graph-sdk https://github.com/facebook/php-graph-sdk

Or要么

https://developers.facebook.com/docs/facebook-login/web/login-button/ https://developers.facebook.com/docs/facebook-login/web/login-button/

In my case, i was requesting granted_scopes along with redirecting to provider就我而言,我请求grant_scopes以及重定向到提供程序

then in callback - and as long as there are required scopes in array of declined scopes , i re-requested back but forgot to set granted scopes again, so i ended up in the redirect loop error between application and facebook.然后在回调中 - 只要拒绝范围数组中有必需的范围,我重新请求返回但忘记再次设置授予的范围,所以我最终陷入了应用程序和 Facebook 之间的重定向循环错误。 Maybe it's your case too.也许这也是你的情况。

There is something wrong with Facebook dashboard at the time of this writing.在撰写本文时,Facebook 仪表板存在问题。

You could wait for the fix or try skipping dashboard by editing the url by replacing "/dashboard/" with "/settings/basic/".您可以等待修复或尝试通过将“/dashboard/”替换为“/settings/basic/”来编辑网址来跳过仪表板。

PS: I had checked browser extensions, cleared browsing history and cookies, disabled Web shields to no avail, only this worked. PS:我检查了浏览器扩展,清除了浏览历史记录和 cookie,禁用了 Web 防护无济于事,仅此而已。

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

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