0

我对“身份验证”对话框中的经过身份验证的推荐有疑问。当用户第一次使用应用程序并请求授权时,他/她会得到“应用程序将收到:您的基本数据”。这与我在 Facebook 开发者应用程序站点中预览身份验证对话框时显示的内容不同。我使用以下代码:

<script>
// Load the SDK Asynchronously
(function(d){
 var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
 if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 ref.parentNode.insertBefore(js, ref);
}(document));

// Init the SDK upon load
window.fbAsyncInit = function() {
  FB.init({
  appId      : '<%= Facebook::APP_ID %>', // App ID
  channelUrl : '//'+window.location.hostname+'/channel', // Path to your Channel File
  status     : true, // check login status
  cookie     : true, // enable cookies to allow the server to access the session
  xfbml      : true  // parse XFBML
});

url = '<%= users_path %>'
// listen for and handle auth.statusChange events
FB.Event.subscribe('auth.statusChange', function(response) {
 if (response.authResponse) {
  // user has auth'd your app and is logged into Facebook
  FB.api('/me', function(me){
    if (me.name) {
      window.open(url);
    }
  })
} else {
  // user has not auth'd your app, or is not logged into Facebook
  document.getElementById('auth-loggedout').style.display = 'block';
}

});

// respond to clicks on the login and logout links
document.getElementById('auth-loginlink').addEventListener('click', function(){
FB.login();

});

}

4

1 回答 1

0

将 FB.login() 替换为

FB.login(function(response) {
   // handle the response
 }, {scope : 'user_likes'});  });
于 2012-09-26T18:01:33.797 回答