开发者

Facebook Login : How do I get the users email?

开发者 https://www.devze.com 2023-03-13 20:02 出处:网络
I\'m new to the facebook api, but I have this: <html> <head> <title>My Facebook Login Page</title>

I'm new to the facebook api, but I have this:

<html>
<head>
  <title>My Facebook Login Page</title>
</head>
<body>
  <div id="fb-root"></div>
  <script src="http://connect.facebook.net/en_US/all.js"></script>
  <script>
     FB.init({ 
        appId:'my_app_id', cookie:true, 
        status:true, xfbml:true 
     });
  </script&开发者_Go百科gt;

  <fb:login-button perms="email">Login</fb:login-button>    

</body>

I would like to know, when a user accepts my perms or when they return to my site, how do I get that users email adderss?


this will help :

FB.api('/me', function(user) { if(user != null){ document.write(user.email); } })

call this function after user gives you permission


Check out the javascript sdk documentation, they have a similar example of doing this. Try something like:

FB.api(
    {
      method: 'fql.query',
      query: 'SELECT email FROM user WHERE uid='+FB.getSession().uid
    },
    function(response) {
          alert('Email is ' +response[0].email);
    }
  );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号