-1

幸运的是,在尝试从 Facebook 帐户获取好友列表时,我得到了一些无法理解的响应,这就是我在 console.log 时得到的结果:

 #v_3 { __wrapped=#v_3, __observableEvents={...}, name="v_3", more...}

The method FB.Data.query:toString is not officially supported by Facebook and access to it will soon be removed.

这是我的登录代码并获取用户的好友列表成员:

    FB.init({ appId:'my_appid' });

    // fetch the status on load
    FB.getLoginStatus(handleSessionResponse);

    $('#login').bind('click', function() {
        FB.login(handleSessionResponse);
    });

    $('#logout').bind('click', function() {
        FB.logout(handleSessionResponse);
    });

    // handle a session response from any of the auth related calls
    function handleSessionResponse() {
        FB.api('/me', function(response) {
            var access_token = FB.getAuthResponse()['accessToken'];
            console.log(access_token);
            console.log(response);
            var friends = FB.Data.query('SELECT uid, flid FROM friendlist_member WHERE flid IN (SELECT flid FROM friendlist WHERE owner=me())');
            console.log(friends);

            $('#user-info').html(response.id + ' - ' + response.name);
        });
    }

有人遇到过同样的问题吗?

4

1 回答 1

3

好吧,有一个更好的方法来获取用户的好友列表:

FB.api('me/friends', function(response) {
   console.log(response);
}

如果您真的想使用 FQL(在这种情况下这不是一个好方法),在此线程中解释了如何将 FQL 与 JavaScript SDK 一起使用:如何使用 Facebook Graph API 执行 FQL 查询

获取朋友的正确 FQL 调用将是这个:

SELECT uid2 FROM friend WHERE uid1=me()

https://developers.facebook.com/docs/reference/fql/

于 2012-11-21T11:11:10.937 回答