I m making a facebook app to display the birthday of a user.........
<?
require_once('php-sdk/facebook.php');
$config = array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?
if($user_id)
{
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try
{
$user_profile = $facebook->api('/me','GET');
echo "Name: " . $user_profile['name'];
// Birth Date to be printed here........
echo "DOB: ".$user_profile['birthday'];
}
catch(FacebookApiException $e)
{
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
}
else
{
// No user, print a link for the user to login
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
Now , the problem is This prints the name as expected but prints nothing in place on date of birth
.......When i referred further, I heard about the term facebook permissions (extended).....
and from the following link
http://developers.facebook.com/docs/reference/api/user/
I found that we need to enable permissions users_birthday
or friends_birthday
.
Now, How do we enable it in php code ??...Please help with samples....... I m sorry if this question seems silly. I m just a new comer in facebook app developing and also a beginner in php....... I tried the other examples in stackoverflow.com and it didn't help me much......
I see no indication you've read the Permission or Authentication documentation; you're not asking the user for permission to access their birthday.
Add user_birthday
to the scope
when sending the user to the Auth Dialog and you'll be able to access their birthday if they approve the permissions.
The permissions you configure in the App Settings only apply to (deprecated) Authenticated Referrals or the App Center login screen, your app needs to explicitly ask for the permissions in all other login flows