用户登录Facebook后获取用户详细信息

时间:2011-03-31 15:23:00

标签: php facebook facebook-graph-api

我的网站上有我的登录按钮,一切正常。但我希望得到用户的电子邮件,名字和姓氏以及Facebook ID并将它们存储在数据库中,一旦我知道了如何将这些添加到数据库,它只是从Facebook获取信息,这是我的问题允许访问基本信息和发送电子邮件我只是想知道我如何获得该信息

我的登录按钮如下所示

script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
           FB.init({ 
            appId:'137558232981530', cookie:true, 
            status:true, xfbml:true 
         });
         $num = 1;
      </script>
      <fb:login-button perms="email, user_about_me, publish_stream">Login with Facebook</fb:login-button>

1 个答案:

答案 0 :(得分:0)

fb-login-button代码在调用您可以订阅的事件时抛出一个事件。试试这个:

<html>
<head>
</head>
<body>

<fb:login-button perms="email,user_about_me,publish_stream"></fb:login-button>

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
    FB.init({ 
        appId:'137558232981530', 
        cookie:true, 
        status:true, 
        xfbml:true 
    });

    FB.Event.subscribe('auth.login', function(response) 
    {
        // handle the response however you want, response should be a session with user info
        // that you can POST to a server-side script and extract whatever data you need.
    });
</script>
</body>
</html>