简体   繁体   中英

getUser() is not working in the Facebook SDK PHP

$response = $fb->get('/me'); 
$userNode = $response->getGraphUser(); 

is working and my name is shown. If I try to follow an example:

//Get the FB UID of the currently logged in user
$user = $facebook->getUser();

Why get_user() is not working?

All I get is this error:

Fatal error: Call to undefined method Facebook\\Facebook::getUser()

You can use $object->getProperty('email'); to get property of user (in this case email)

I can see fb-userid by using below code in callback php:

$accessToken = $helper->getAccessToken();
......
$oAuth2Client = $fb->getOAuth2Client();
// Get the access token metadata from /debug_token    
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
var_dump($tokenMetadata);

which you can format as per the requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM