我更新了我的facebook api,我试图发起这样的会议,
FacebookSession::setDefaultApplication( 'foo foo','foo foo' );
我在该行上收到此错误,
Fatal error: Class 'facebook\src\Facebook\FacebookSession'not found in /foo/foo/foo/header.php on line 41
我的档案路径正确......
有什么想法吗?
这是我的完整代码,
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// include required files form Facebook SDK
// added in v4.0.5
require_once( 'facebook/src/Facebook/FacebookHttpable.php' );
require_once( 'facebook/src/Facebook/FacebookCurl.php' );
require_once( 'facebook/src/Facebook/FacebookCurlHttpClient.php' );
require_once( 'facebook/src/Facebook/FacebookSession.php' );
require_once( 'facebook/src/Facebook/FacebookRedirectLoginHelper.php' );
require_once( 'facebook/src/Facebook/FacebookRequest.php' );
require_once( 'facebook/src/Facebook/FacebookResponse.php' );
require_once( 'facebook/src/Facebook/FacebookSDKException.php' );
require_once( 'facebook/src/Facebook/FacebookRequestException.php' );
require_once( 'facebook/src/Facebook/FacebookOtherException.php' );
require_once( 'facebook/src/Facebook/FacebookAuthorizationException.php' );
require_once( 'facebook/src/Facebook/GraphObject.php' );
require_once( 'facebook/src/Facebook/GraphSessionInfo.php' );
use facebook\src\Facebook\FacebookHttpable;
use facebook\src\Facebook\FacebookCurl;
use facebook\src\Facebook\FacebookCurlHttpClient;
use facebook\src\Facebook\FacebookSession;
use facebook\src\Facebook\FacebookRedirectLoginHelper;
use facebook\src\Facebook\FacebookRequest;
use facebook\src\Facebook\FacebookResponse;
use facebook\src\Facebook\FacebookSDKException;
use facebook\src\Facebook\FacebookRequestException;
use facebook\src\Facebook\FacebookOtherException;
use facebook\src\Facebook\FacebookAuthorizationException;
use facebook\src\Facebook\GraphObject;
use facebook\src\Facebook\GraphSessionInfo;
// start session
session_start();
// init app with app id and secret
FacebookSession::setDefaultApplication( 'foo foo','foo foo' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper( 'http://www.wuno.com/sandbox/' );
// see if a existing session exists
if ( isset( $_SESSION ) && isset( $_SESSION['fb_token'] ) ) {
// create new session from saved access_token
$session = new FacebookSession( $_SESSION['fb_token'] );
// validate the access_token to make sure it's still valid
try {
if ( !$session->validate() ) {
$session = null;
}
} catch ( Exception $e ) {
// catch any exceptions
$session = null;
}
} else {
// no session exists
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
// handle this better in production code
print_r( $ex );
} catch( Exception $ex ) {
// When validation fails or other local issues
// handle this better in production code
print_r( $ex );
}
}
// see if we have a session
if ( isset( $session ) ) {
// save the session
$_SESSION['fb_token'] = $session->getToken();
// create a session using saved token or the new one we generated at login
$session = new FacebookSession( $session->getToken() );
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject()->asArray();
// print profile data
echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';
// print logout url using session and redirect_uri (logout.php page should destroy the session)
echo '<a href="' . $helper->getLogoutUrl( $session, 'http://www.wuno.com/sandbox/actions/fbLogout.php' ) . '">Logout</a>';
} else {
// show login url
echo '<a href="' . $helper->getLoginUrl( array( 'email', 'user_friends' ) ) . '">Login</a>';
}
echo 'sup dude';
?>