facebook connect访问令牌另存为php会话破解代码
我正在尝试将访问令牌作为php会话传递 奇怪的事情发生了,我不明白为什么 fbconfig.fbfacebook connect访问令牌另存为php会话破解代码,php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,我正在尝试将访问令牌作为php会话传递 奇怪的事情发生了,我不明白为什么 fbconfig.fb 到目前为止还不错。 我获得连接,获得访问令牌并将用户发送到index.php php是facebook连接的起点,我检查是否有facebook会话。如果我没有将用户发送到上面的文件fbconfig.php,那么我将用户发送到html5应用程序(一个名为mobile.php的文件) 无论如何,当我尝试访问mobile.php中的$_会话['accesstoken']时,代码中断。代码只是在我试图输
到目前为止还不错。
我获得连接,获得访问令牌并将用户发送到index.php
php是facebook连接的起点,我检查是否有facebook会话。如果我没有将用户发送到上面的文件fbconfig.php,那么我将用户发送到html5应用程序(一个名为mobile.php的文件)
无论如何,当我尝试访问mobile.php中的$_会话['accesstoken']时,代码中断。代码只是在我试图输出会话的地方结束,我不明白为什么
<?php
session_start();
// added in v4.0.0
require_once 'autoload.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( 'xxxxxxxx','xxxxxxxxx' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper('http://www.something.net/triviapp/1353/fbconfig.php' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
$firstname = $graphObject->getProperty('first_name');
$lastname = $graphObject->getProperty('last_name');
$femail = $graphObject->getProperty('email'); // To Get Facebook email ID
/* ---- Session Variables -----*/
$_SESSION['FBID'] = $fbid;
$_SESSION['FULLNAME'] = $fbfullname;
$_SESSION['EMAIL'] = $femail;
$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$accessToken = $session->getAccessToken();
$_SESSION['accesstoken'] = $accessToken;
//echo $_SESSION['accesstoken'];
/* ---- header location after session ----*/
header("Location: index.php");
} else {
$loginUrl = $helper->getLoginUrl();
header("Location: ".$loginUrl);
}
?>