登录后,应用程序应该打印我的家乡和我喜欢的Facebook,但它打印任何东西,我该怎么做?代码只打印我的ID,我的全名,我的照片和生日。我试图找到一些解决方案,但它不起作用。
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me?fields=email,name,hometown,location,friends,age_range,birthday');
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id');
$fbfullname = $graphObject->getProperty('name');
$fbuser_location = $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');
$fbuser_likes = $graphObject->getProperty('user_likes');
// ********** PRINT GRAPH *********************
$graphArray = $response->getGraphObject()->AsArray();
echo '<pre>' . print_r( $graphArray, 1 ) . '</pre>';
// ********************************************
$_SESSION['FBID'] = $fbid;
$_SESSION['FULLNAME'] = $fbfullname;
$_SESSION['HOMETOWN'] = $fbhometown;
$_SESSION['AGE_RANGE'] = $fbage_range;
$_SESSION['USER_ABOUT_ME'] = $fbuser_about_me;
$_SESSION['BIRTHDAY'] = $fbbirthday;
$_SESSION['EMAIL'] = $fbemail;
$_SESSION['USER_LIKES'] = $fbuser_likes;
$loginUrl = $helper->getLoginUrl(array('scope' => 'email, public_profile, user_friends,user_location,user_friends,user_about_me'));
header("Location: ".$loginUrl);
}
} catch( Exception $ex ) {
echo $ex->getMessage();
}
?>
here i copy the mainpag
<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">Facebook Location</li>
<li><?php echo $_SESSION['USER_HOMETOWN']; ?></li>
<li class="nav-header">User Likes</li>
<li><?php echo $_SESSION['USER_LIKES']; ?></li>
<div>
<a href="logout.php">Logout</a>
</div>
</ul>
</div>
</div>
<?php else: ?> <!-- Before login -->