最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Email permissions not working in Facebook through the JavaScript SDK - Stack Overflow

programmeradmin3浏览0评论

I am trying this script:

FB.login({scope: 'email'},function(response){
                if(response.status == 'connected'){
                    alert('I am connected')
                }
            });

But it is not asking the user to give permissions on email.. :(

I tried both scope and perms as parameters.

References:

  • Graph API, Permissions
  • Facebook authentication

I am trying this script:

FB.login({scope: 'email'},function(response){
                if(response.status == 'connected'){
                    alert('I am connected')
                }
            });

But it is not asking the user to give permissions on email.. :(

I tried both scope and perms as parameters.

References:

  • Graph API, Permissions
  • Facebook authentication
Share Improve this question edited Jan 8, 2012 at 7:05 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Sep 5, 2011 at 7:32 makkimakki 2,1073 gold badges23 silver badges37 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Found out your mistake, the signature of the function is FB.login(callback function(), {options}), rest is Okay.

FB.login(function(response){
            if(response.status == 'connected'){
                alert('I am connected')
            }
        },{scope: 'email'});

reference: https://developers.facebook./docs/reference/javascript/FB.login/

Here is a full working example, just plug in your app id.

<!DOCTYPE html>
<html>
<body>
<div id="fb-root"></div>
<a href="#" onclick="getEmail();return false;">Get Email</a>
<script src="http://connect.facebook/en_US/all.js"></script>
<script>
  FB.init({ appId: '**AppID**', status: true, cookie: true, xfbml : true });

  function getEmail() {  
    FB.login(function(response) {
      if (response.session && response.perms) {
        FB.api('/me',  function(response) {
            alert('Email: ' + response.email);
          }
        );
      }
    } , {scope:'email'}); 
}
</script>
</body>
</html>
发布评论

评论列表(0)

  1. 暂无评论