php - Get user birthday Facebook Graph -
i want collect information when user log in through facebook. i'm able information need except users birthday
if ( isset( $session ) ) { // graph api request user data $request = new facebookrequest( $session, 'get', '/me?fields=first_name,last_name,birthday,email,gender'); $response = $request->execute(); // response $graphobject = $response->getgraphobject(); $fbid = $graphobject->getproperty('id'); // facebook id $fbfname = $graphobject->getproperty('first_name'); // facebook first name $fblname = $graphobject->getproperty('last_name'); // facebook last name $fbbday = $graphobject->getproperty('birthday'); // facebook birthday $femail = $graphobject->getproperty('email'); // facebook email id $fgender = $graphobject->getproperty('gender'); // facebook gender /* ---- session variables -----*/ $_session['fbid'] = $fbid; $_session['first_name'] = $fbfname; $_session['last_name'] = $fblname; $_session['birthday'] = $fbbday; $_session['email'] = $femail; $_session['gender'] = $fgender; checkuser($fbid,$fbfname,$femail); /* ---- header location after session ----*/ header("location: index.php"); } else { $loginurl = $helper->getloginurl(array('scope' => 'email')); header("location: ".$loginurl); } ?>
what doing wrong?
you don´t ask correct permission:
$loginurl = $helper->getloginurl(array('scope' => 'email,user_birthday'));
btw, make sure test app admin. user_birthday
needs reviewed before can use it: https://developers.facebook.com/docs/facebook-login/review
Comments
Post a Comment