Enable user_birthday facebook birthday permission in php

I am making a facebook application to display the user's birthday .........

<? 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 mentioned later, I heard about facebook rights terms (extended) ..... and from the following http link : //developers.facebook.com/docs/reference/api/user/

I found that we need to allow permissions of users_birthday or friends_birthday .

Now how to enable it in php code? ... Please help with samples ....... I'm sorry if this question seems silly. I am just a new user in Facebook development, and also new to php ....... I tried other examples at stackoverflow.com and it didn’t help me much ...

+4
source share
2 answers

I see no signs that you read Permission or Authentication ; You do not ask the user for permission to access your birthday.

Add user_birthday to scope when sending the user to the Auth dialog box, and you can access your birthday if they approve the permissions.

The permissions that you configure in the application settings apply only to (outdated) authenticated referrals or the application center login window, your application must explicitly request permissions in all other login flows

+4
source

You must ask Facebook to approve your application. After viewing facebook you can use advanced permissions.

According to this Documentation, if your application requests more than public_profile, email and user_friends, this will require consideration by Facebook before your application can be used by people other than application developers. 1

I had the same problem as you. I thought it was wrong, that’s it. Then I just saw this on the facebook v2.0 documentation.

+3
source

Source: https://habr.com/ru/post/1432807/


All Articles