0

我正在通过 facebook 的 Javascript SDK 将用户登录到一个网站。用户单击“通过 fb 登录”按钮后,我想根据用户在 facebook 的确认中单击“确定”还是“取消”来生成不同的响应。这是我在他们单击 fb 按钮时使用的代码。

$("#fb").click(function() {
    FB.login(function(response){
        FB.api('/me',function(response){

            // I believe the test to see if they are logged in or not should go here

        });//FB.api
    },{scope:'publish_actions, email, user_likes, user_location'});
});

任何建议表示赞赏。谢谢!

4

1 回答 1

0

根据facebook的文档

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    // the user is logged in and has authenticated your
    // app, and response.authResponse supplies
    // the user's ID, a valid access token, a signed
    // request, and the time the access token 
    // and signed request each expire
    alert('a');
  } else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    // but has not authenticated your app
    alert('b');
  } else {
    // the user isn't logged in to Facebook.
    alert('c');
  }
 });

它对我有用。希望它可以帮助别人。

于 2013-07-01T19:53:50.740 回答