Francesco Francesco - 9 months ago 139
PHP Question

Facebook PHP SDK Age Range

I'm creating a facebook application that allows users to register at my site using data from facebook, then I need to retrieve these data.

The code I wrote is as follows:

$request = new FacebookRequest(
$response = $request->execute();
$graphObject = $response->getGraphObject();
$user = $response->getGraphObject(GraphUser::className());

And then I get some information with:

echo "Name: " . $graphObject->getProperty('name');
echo "<br/>";
echo "Email: " . $graphObject->getProperty('email');


The problem is that I don't know how to get the age range, because if I try

echo "Age range: " . $graphObject->getProperty('age_range');


echo "Age range: " . $graphObject->getProperty('agerange');

It returns an empty space, without providing any data.

So, how can I retrieve age range infos?


age_range is not a default field so you will have to ask for it using /me?fields=age_range