0
I am using version 2.9 of the Facebook Api in PHP, my goal is to recover the most basic information.
From what I read in the documentation, the only authorization I would need is the email address, which I already have. First Name and Last Name would not require additional authorization
But when executing
$loader = require __DIR__ . '\..\vendor\autoload.php';
$token = $_POST['token'];
include './Facebook/Facebook.php';
$fb = new \Facebook\Facebook([
'app_id' => 'meu id aqui',
'app_secret' => 'meu segredo aqui',
'default_graph_version' => 'v2.9',
'default_access_token' => $token
]);
$helper = $fb->getRedirectLoginHelper();
$response = $fb->get('/me',$token);
$me = $response->getGraphUser();
echo json_encode(array(
"resultado" => true,
"id" => $me->getId(),
"name" => $me->getName(),
"fields" => $me->getFieldNames(),
"email" => $me->getEmail(),
"cover" => $me->getField("cover"),
"firstname" => $me->getFirstName(),
"lastname"=>$me->getLastName(),
"picture" => $me->getPicture()
));
I just get
- id
- name
All other fields are null
When passing through parameter no get('/me?fields=email,name,id,lastname,firstname')
, PHP sends the error
Graph returned an error: (#100) Tried accessing nonexisting field (lastname) on Node type (User)*
How to recover this information with the API?
It worked properly, thank you.
– Sveen