Facebook login not redirecting [closed]

♀尐吖头ヾ 提交于 2019-12-06 09:21:45

I used this solution in php:

$loginUrl = $facebook->getLoginUrl(array(
            'scope' => $scope,
            'redirect_uri' => $app_url,
            ));


            echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";

Try this:

$facebook = new Facebook(array(
  'appId'  => '', // app id
  'secret' => '', // the secret
));

// Get User ID
$user = $facebook->getUser();

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
  header("Location: ".$login_url); // the user is not logged in, redirect him to the login page
  exit();
}

Figured out the problem. I had a typo... I was assigning the url to $logoutUrl and was trying to get the url from $logout_url...

Thanks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!