开发者

fb:login-button doesnt work without show-faces

We just switched to new PHP SDK and JS today. but the problem is weird. When we dont use show-faces with perms attribute it doesnt show popup. Only way to get permission popup appear, we need to use show-faces attr.

is this a bug ?

<fb:login-button perms="email, publish_stream, offline_access, create_event, user_photos, user_online_presence, user_videos, user_website, user_events, user_relationships, user_interests" size="large">Sign Up With Facebook</fb:login-button>

<div id="fb-root"></div>
  <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId: '<?php echo $facebook->getAppID() ?>',
          cookie: true,
          xfbml: t开发者_StackOverflow中文版rue,
          oauth: true
        });
        FB.Event.subscribe('auth.login', function(response) {
          window.location.reload();
        });
        FB.Event.subscribe('auth.logout', function(response) {
          window.location.reload();
        });
      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>

Thanks

EDIT:

OMG. i just found the solution, with the new JS SDK we must use scope instead of perms attribute!


with the new JS SDK we must use scope instead of perms attribute!


Alternatively you can use straight Javascript and make your own buttons.

<script>
    function addPermissions(permissions){
        FB.login(function(response) {
            if (response.session) {
                if (response.perms) {
                    // user is logged in and granted some permissions.

                } else {
                    // user is logged in, but did not grant any permissions

                }
            } else {
                // user is not logged in
            }
        }, {perms:permissions});
    }
</script>
<a onclick="addPermissions("email, publish_stream,...");">Click me</a>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜