1
這裏是我的代碼:Facebook登錄SDK PHP 4.0的錯誤登錄
<?php
session_start();
require_once('Facebook/FacebookSession.php');
require_once('Facebook/FacebookRedirectLoginHelper.php');
require_once('Facebook/FacebookRequest.php');
require_once('Facebook/FacebookResponse.php');
require_once('Facebook/FacebookSDKException.php');
require_once('Facebook/FacebookRequestException.php');
require_once('Facebook/FacebookAuthorizationException.php');
require_once('Facebook/GraphObject.php');
require_once('Facebook/GraphUser.php');
require_once('Facebook/GraphSessionInfo.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\GraphUser;
use Facebook\GraphSessionInfo;
$id = 'xxxxx';
$secret = 'xxxxx';
FacebookSession::setDefaultApplication($id, $secret);
$helper = new FacebookRedirectLoginHelper('http://da-404.hol.es/FD/index.php');
try{
$session = $helper->getSessionFromRedirect();
}catch(Exception $e){
}
if(isset($_SESSION['token'])){
$session = new FacebookSession($_SESSION['token']);
try{
$session->Validate($id, $secret);
}catch(FacebookAuthorizationException $e){
$session = '';
}
}
if(isset($session)){
$_SESSION['token'] = $session->getToken();
echo "Login Successful<br>";
$request = new FacebookRequest($session, 'GET', '/me');
$response = $request->execute();
$graph = $response->getGraphObject(GraphUser::className());
echo "Hi " . $graph->getName();
}
else{
echo "<a href = " . $helper->getLoginUrl() . ">Login With Facebook</a>";
}
即使我登錄與FB,我的FB名不會出現。
iamge:http://prntscr.com/5n6iud
我的名字不會出現,甚至連登錄令牌秀...
什麼問題?