php - Facebook connect api cannot get email -


i've set scope on login button, asks permission email can't email info. i'm testing fyi have main email , it's approved.

i did this, didn't solve problem: facebook email field return null (even if “email” permission set , accepted)

this code:

define('your_app_id', 'x'); define('your_app_secret', 'x');  include_once 'facebook/facebook.php';  $facebook = new facebook(array(  'appid' => your_app_id,  'secret' => your_app_secret, ));  $userid = $facebook->getuser();  <script> window.fbasyncinit = function() {  fb.init({  appid : <?=your_app_id?>,  status : true,  cookie : true,  xfbml : true,  oauth : true,  });   fb.event.subscribe('auth.login', function(response) {         loading(1);          <?         if ($userid) {         $userinfo = $facebook->api('/' + $userid + '?locale=en_us&fields=id,name,email');           }         ?>         var mail = "<?=$userinfo['email']?>";          $.post("<?=$sozlukscripti["path"]?>inc/reglogin.php", { islem: "fbgiris", mail: mail }, function(data) {             if(data) {                 location.reload();             }             else {                 $.pnotify({title: 'giriş başarısız', text: '<? _e("k. adı & mail ya da şifre yanlış"); ?>', type: 'error'});             }         loading();         });          return false;  });   };  (function(d){  var js, id = 'facebook-jssdk'; if (d.getelementbyid(id)) {return;}  js = d.createelement('script'); js.id = id; js.async = true;  js.src = "//connect.facebook.net/en_us/all.js";  d.getelementsbytagname('head')[0].appendchild(js);  }(document)); </script> 

reglogin.php sets sessions members. if set var mail email (user@example.com), code works. can't email facebook connect.

my button code:

<div id="fb-root"></div> <fb:login-button scope="email"></fb:login-button> 

thank in advence.

thanks help(!)

i'm amatour web designer. guess made big mistake in javascript code.

var mail = "<?=$userinfo['email']?>"; 

changed javascript code this:

<? if ($userid) { $userinfo = $facebook->api('/' + $userid + '?locale=en_us&fields=id,name,email'); $_session['email'] = $userinfo['email']; } ?> var mail = "<?=$_session['email']?>"; 

now works. can explain why didn't work @ first time?

noob here


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -