1

这是我正在使用的完整代码片段。我已经阅读了所有文档,但仍然无法弄清楚这一点。我在 Visual Studio 2010 和 chrome 浏览器上本地运行代码。我已将我的站点 url、画布 url 和安全画布 url 设置为 localhost。我的应用程序域为空。我猜我做错了什么,我无法弄清楚。请帮我

<html>

 <body>

   <div id="fb-root"></div>


     <script>

         window.fbAsyncInit = function() {
          FB.init({
            appId      : '129307260602861',
            status     : true, 
            cookie     : true,
            xfbml      : true,
            oauth      : true,
          });

     FB.Event.subscribe('auth.login', function(response) {
       fblogin(); //first login time
    });

    FB.Event.subscribe('auth.authResponseChange', function(response) {
  alert('The status of the session is: ' + response.status);});

    FB.Event.subscribe('auth.logout', function(response) {
        alert('logout');
    });


    };

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


   function fblogin() {

    FB.getLoginStatus(function(response) {

        if (response.status === 'connected') {
            //check extened permisions
            var access_token =  response.authResponse.accessToken;
            var user_id = response.authResponse.userID;
       // Do your business
        alert('here');
        }
        else {
            //user is not logged in
            alert('here');
        }
    });

}
    </script>

   <fb:login-button autologoutlink='true' perms='email,user_birthday,status_update,publish_stream'></fb:login-button>
 </body>

 </html>
4

0 回答 0