0

我在我的 asp.net 项目中从 facebook 获取了用户个人资料信息,包括用户名、生日、电子邮件、个人资料图片和性别,现在我想获取城市和关于我的详细信息,我尝试了与以前相同的方式来获取这些信息,但不幸的是我我做不到。

我点击此链接查看扩展配置文件权限,但我仍然无法做到这一点。

这是我的脚本

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <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: '155578484623690', // App ID
                channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
                scope: 'id,name,gender,user_birthday,email,user_about_me,user_location',
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });
            // 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
                    var uid = "http://graph.facebook.com/" + response.authResponse.userID + "/picture";
                    FB.api('/me', function (me) {
                        if (me.name) {
                            document.getElementById('txtDisplayName').innerHTML = me.name;
                            document.getElementById('Email').innerHTML = me.email;
                            document.getElementById('BD').innerHTML = me.birthday;
                            document.getElementById('profileImg').src = uid;
                            document.getElementById('Gender').innerHTML = me.gender;
                            document.getElementById('city').innerHTML = me.about;
                            document.getElementById('city').innerHTML = me.location;
                        }
                    })
                    document.getElementById('auth-loggedout').style.display = 'none';
                    document.getElementById('auth-loggedin').style.display = 'block';
                } else {
                    // user has not auth'd your app, or is not logged into Facebook
                    document.getElementById('auth-loggedout').style.display = 'block';
                    document.getElementById('auth-loggedin').style.display = 'none';
                }
            });
            $("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); });
        }
    </script>
4

1 回答 1

0

根据有关用户的文档,

  • 没有像aboutUser 那样的字段,而是用于 Page 对象。对于用户,您可能想要的字段是bio

  • 其次,location字段还包含id位置name。因此,您不想使用me.location您想me.location.name用于用户位置的名称

于 2013-05-13T11:05:41.550 回答