简体   繁体   English

Facebook SDK PHP重定向循环

[英]Facebook SDK PHP Redirect loop

When i have no session made it displays the login page right away, but once i login i go into a "Redirect Loop" error from chrome, ive tried diferent stuff and the problem seams that i never end up with a $session. 当我没有会话时,它会立即显示登录页面,但是一旦我登录,我就会遇到chrome出现的“重定向循环”错误,我尝试了不同的东西,并且出现了问题,这些问题我从来没有以$ session结尾。 the code below is the only thing that i have currently its login.php page. 下面的代码是我目前仅有的login.php页面。

<?php
session_start();
// added in v4.0.0
require_once "facebook-php-sdk-v4-4.0-dev/autoload.php";
//require 'functions.php';  
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// init app with app id and secret
FacebookSession::setDefaultApplication('APPID','APPSCRET');
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper( 'http://fbtwitsergio.byethost12.com/login.php' );
try {
    $session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
    // When Facebook returns an error
} catch( Exception $ex ) {
    // When validation fail ———got a echo from here
}
// see if we have a session
if ( isset( $session ) ) {
    header("Location: index.php");
} else {
    $loginUrl = $helper->getLoginUrl();
    header("Location: ".$loginUrl);
}
?>

已经发现出了问题。。。服务器很可能已关闭端口,因此无法连接到FB SDK。

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

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