lundi 2 mars 2015

facebook php sdk: retrieve user information

I have a problem with retrieve basic user information. This is my code:



require_once 'facebook-php-sdk/autoload.php';
FacebookSession::setDefaultApplication('appid', 'appsecret');

try {
$token = 'mytoken';
$session = new FacebookSession($token);
$request = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className());
$username = $request->getName();

echo $username . '<br>';
} catch (FacebookRequestException $e) {
echo'Error';
echo $e;
}


but no exception is throws, and nothing is printed. What's wrong?


Aucun commentaire:

Enregistrer un commentaire