繁体   English   中英

登录 facebook 错误:ERR_TOO_MANY_REDIRECTS

[英]Login with facebook error: ERR_TOO_MANY_REDIRECTS

我正在尝试使用 facebook 登录,但我收到太多重定向错误。 请帮助我如何修复它。

我试过浏览器 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);
}

?>

请查看代码并帮助我修复此重定向错误,我总是在其他部分出错。

登录 facebook 错误:ERR_TOO_MANY_REDIRECTS

您的Facebook Plugin似乎存在一些问题,这就是$user为 0 的原因。这背后也可能有许多其他原因。 您还需要重新检查您的APP_IDAPP_SECRET

最重要的是,您需要按照以下链接进行相应更新。

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

要么

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

就我而言,我请求grant_scopes以及重定向到提供程序

然后在回调中 - 只要拒绝范围数组中有必需的范围,我重新请求返回但忘记再次设置授予的范围,所以我最终陷入了应用程序和 Facebook 之间的重定向循环错误。 也许这也是你的情况。

在撰写本文时,Facebook 仪表板存在问题。

您可以等待修复或尝试通过将“/dashboard/”替换为“/settings/basic/”来编辑网址来跳过仪表板。

PS:我检查了浏览器扩展,清除了浏览历史记录和 cookie,禁用了 Web 防护无济于事,仅此而已。

暂无
暂无

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

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