Facebook注册没有出现

时间:2012-04-09 12:33:46

标签: jquery facebook

我正在检查用户是否已注册我的应用程序,如果没有,我正在尝试显示Facebook注册按钮,但它没有显示。

以下是我在网页页脚中的javascript代码:

<div id="fb-root"></div>
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId   : '281914178557709',
      status  : true, // check login status
      cookie  : true, // enable cookies to allow the server to access the session
      xfbml   : true // parse XFBML
    });

    FB.getLoginStatus(function(response) {
      if (response.status === 'connected') {
        var uid = response.authResponse.userID;
        var accessToken = response.authResponse.accessToken;
      } 
      else if (response.status === 'not_authorized') {
        alert("Show registration");
        $('#fb_register').html('<label class="control-label" for="fname">&nbsp;</label><div class="controls"><fb:login-button registration-url="/register_facebook.php" /></div>');
      }
   });             
};

(function() {
  var e = document.createElement('script');
  e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
  e.async = true;
  document.getElementById('fb-root').appendChild(e);
}());

我的div标签就是这样:

<div class="control-group" id="fb_register"></div>

我看到了我的警告信息,所以我知道我正在击中正确的区域,但按钮无法渲染。如果我使用直文,它会渲染。知道为什么没有渲染XFBML吗?

1 个答案:

答案 0 :(得分:1)

我相信在插入facebook登录按钮之前正在解析xfbml,最好的方法是将facebook登录按钮包装在div中并将其显示设置为none,然后将用户的显示切换为阻止经过验证。