此代码在localhost中显示完整的FB详细信息,但仅显示实时服务器中的ID和名称。
if ($session){ //if we have the FB session
//get user data
$user_profile = (new FacebookRequest($session, 'GET', '/me'));
$response = $user_profile->execute();
$graphObject = $response->getGraphObject();
// print data
echo print_r( $graphObject, 1 );
}
示例Localhost输出(完整公共详细信息):
Facebook\GraphObject Object ( [backingData:protected] => Array ( [id] => 101 [email] => myEmail@gmail.com [first_name] => MyFname [gender] => male [last_name] => MyLName[link] => https://www.facebook.com/app_scoped_user_id/101/ [locale] => en_US [name] => MyFname MyLname [timezone] => 4 [updated_time] => 2015-05-18T05:51:40+0000 [verified] => 1 ) )
实时服务器输出示例(仅限Fb ID和全名 ):
Facebook\GraphObject Object ( [backingData:protected] => Array ( [name] => Name LastName [id] => 101 ) )
权限:全部设置
$required_scope = 'public_profile, email';
感谢您的帮助(IA)。