PHP Sdk Facebook 4.0错误

时间:2014-05-22 12:55:03

标签: php facebook facebook-graph-api

我已经设置了我的facebook sdk 4.0脚本,这很好。除了我收到很多错误。当我互相修复时,会显示一个。我终于修补了所有的错误,所有我看到的是这个?我看到的错误,只是无法找到类文件所以我需要所需的文件。我使用的域名是在我的system32 C:\ windows \ system32 \ drivers \ etc \ hosts中的主机文件中,我的网站页面上的所有内容都是以下内容?

Facebook\GraphObject Object ( [backingData:protected] => Array ( [id] => 397011563769936 [first_name] => Fernando [gender] => male [last_name] => Smith [link] => https://www.facebook.com/app_scoped_user_id/397011563769936/ [locale] => en_GB [name] => Fernando Smith [timezone] => 1 [updated_time] => 2014-05-17T01:35:48+0000 [verified] => 1 ) )

这是我的index.php,我拥有的所有文件都是index.php和文件夹" Facebook"所有的facebook sdk文件都在。它的例子来自facebook,所以他们不应该有任何问题吗?

<?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' );

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;

// init app with app id (APPID) and secret (SECRET)            
   FacebookSession::setDefaultApplication('***************','********************************');

// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper( 'http://iamawsome.com/fb/' );

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();

// print data
echo  print_r( $graphObject, 1 );
} else {
// show login url
echo '<a href="' . $helper->getLoginUrl() . '">Login</a>';
}    
?>

0 个答案:

没有答案