How to read the date of birth in Facebook Facebook API

I chased my tail! And it should be so simple!

I have an application in FaceBook that works great. However, I need to get the user's date of birth. I have successfully received a request for advanced permissions, but I can not get the date of birth in the database / storage in the database.

<?php
require_once('facebook.php');
$facebook = new Facebook(array(
'appId'  => 'xxxxx',
'secret' => 'yyyyyyy',
'cookie' => true
));
if ($facebook->getSession()) { 
$uid = $facebook->getUser();
$fbme = $facebook->api('/me');
} else {
$params = array(
    'fbconnect'=>0,
    'canvas'=>1,
    'req_perms'=>'publish_stream','email','user_location','user_birthday'
);
$loginUrl = $facebook->getLoginUrl($params);
print "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
}
$session = $facebook->getSession();
$token = $session['access_token'];

I would really appreciate it if someone could show me the PHP code that reads advanced permissions and puts the results in variables.

Thanks Steve

+3
source share
4 answers

Code Section ...

if ($facebook->getSession()) {
$uid = $facebook->getUser();          
$fbme = $facebook->api('/me');          
} else {          
$params = array(     
'fbconnect'=>0,
'canvas'=>1,    
'req_perms'=>'publish_stream','email','user_location','user_birthday' 
); 

Must read ....

if ($facebook->getSession()) {
$uid = $facebook->getUser();          
$fbme = $facebook->api('/me');          
} else {          
$params = array(     
'fbconnect'=>0,
'canvas'=>1,    
'req_perms'=>'publish_stream,email,user_location,user_birthday'
); 

(change the note to the string "req_perms"). Birthday can be read as

$birthday=$fbme['birthday'];

, , $fbme ['birthday'] NULL.

, , , , .

! , .

Facebook API - !

+2

, , , , .

" โ†’ โ†’ " - "- > ". .

+1

Linux

NOW = $( + "% m/% d" )

curl "https://api.facebook.com/method/fql.query?access_token=[ACCESS_TOKEN]&query=SELECT%20first_name,uid%20from%20user%20where%20uid%20in%20(SELECT %20uid2 %20from %20friend %20where %20uid1 = [YourFaceID]) %20substr (birthday_date, 0,5) %20 %20 == '$ NOW'"

0

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


All Articles