salve a tutti, sto realizzando un app che estragga i dati degli utenti che si loggano a questa determinata applicazione, solo che alcuni campi come foto profilo, ID, nome completo, compleanno e genere vengono stampati dall'applicazione mentre gli altri no....sapreste dirmi perchè?
questa sotto è la pagina di configurazione dell'app dove inserisco le richieste, dopo questa parte di codice allego l'index
(perdonatemi la pessima indentazione)
[PHP]
<?php
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;
session_start();
// added in v4.0.0
try {
//init app with app id and secret
FacebookSession::setDefaultApplication( 'xxx','yyy' );
//login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper('http://estrazionedatifb-infouma.rhcloud.com/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?fields=email,name,hometown,gender,location,spor ts,interested_in,friends,age_range,birthday');
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id');
$fbfullname = $graphObject->getProperty('name');
$fbuser_hometown = $graphObject->getProperty('user_hometown');
$fbpublic_profile = $graphObject->getProperty('public_profile');
$fbuser_about_me = $graphObject->getProperty('user_about_me');
$fbbirthday = $graphObject->getProperty('birthday');
$fbmail = $graphObject->getProperty('email');
$fbeducation = $graphObject->getProperty('education');
$fbgender = $graphObject->getProperty('gender');
$fbage_range = $graphObject->getProperty('age_range');
$fbinterested_in = $graphObject->getProperty('interested_in');
$fbcover = $graphObject->getProperty('cover');
$fbsports = $graphObject->getProperty('sports');
// ********** PRINT GRAPH *********************
$graphArray = $response->getGraphObject()->AsArray();
echo '<pre>' . print_r( $graphArray, 1 ) . '</pre>';
// ********************************************
$_SESSION['FBID'] = $fbid;
$_SESSION['FULLNAME'] = $fbfullname;
$_SESSION['HOMETOWN'] = $fbuserhometown;
$_SESSION['AGE_RANGE'] = $fbage_range;
$_SESSION['USER_ABOUT_ME'] = $fbuser_about_me;
$_SESSION['BIRTHDAY'] = $fbbirthday;
$_SESSION['EMAIL'] = $fbemail;
$_SESSION['EDUCATION'] = $fbeducation;
$_SESSION['GENDER'] = $fbgender;
$_SESSION['INTERESTED_IN'] = $fbinterested_in;
$_SESSION['SPORTS'] = $fbsports;
$_SESSION['COVER'] = $fbcover;
header("Location: http://estrazionedatifb-infouma.rhcloud.com/index.php");
} else {
$loginUrl = $helper->getLoginUrl(array('scope' => 'email, public_profile,user_friends,user_location,user_lik es,user_hometown,user_friends,user_about_me'));
header("Location: ".$loginUrl);
}
} catch( Exception $ex ) {
echo $ex->getMessage();
}
?>
<?php
session_start();
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>Login with Facebook</title>
<link href="http://www.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<?php if (isset($_SESSION['FBID']) && $_SESSION['FBID']): ?> <!-- After user login -->
<div class="container">
<div class="hero-unit">
<h1>Hello <?php echo $_SESSION['USERNAME']; ?></h1>
<p>Welcome to "facebook login" tutorial</p>
</div>
<div class="span20">
<ul class="nav nav-list">
<li class="nav-header">Image</li>
<li><img src="https://graph.facebook.com/<?php echo $_SESSION['FBID']; ?>/picture"></li>
<li class="nav-header">Facebook ID</li>
<li><?php echo $_SESSION['FBID']; ?></li>
<li class="nav-header">Facebook fullname</li>
<li><?php echo $_SESSION['FULLNAME']; ?></li>
<li class="nav-header">Facebook Email</li>
<li><?php echo $_SESSION['EMAIL']; ?></li>
<li class="nav-header">Facebook Birthday</li>
<li><?php echo $_SESSION['BIRTHDAY']; ?></li>
<li class="nav-header">User Likes</li>
<li><?php echo $_SESSION['USER_LIKES']; ?></li>
<li class="nav-header">Gender</li>
<li><?php echo $_SESSION['GENDER']; ?></li>
<li class="nav-header">Interested In</li>
<li><?php echo $_SESSION['INTERESTED_IN']; ?></li>
<div>
<a href="logout.php">Logout</a>
</div>
</ul>
</div>
</div>
<?php else: ?> <!-- Before login -->
<div class="container">
<h1>Login with Facebook</h1>
Not Connected
<div>
<a href="fbconfig.php">Login with Facebook</a>
</div>
<!--<div>
<a href="http://www.krizna.com/general/login-with-facebook-using-php/" title="Login with facebook">View Post</a>
</div>-->
</div>
<?php endif ?>
</body>
</html>