1

FQL を使用して各友達のステータスのリストを取得できるようにする Javascript で Facebook アプリを構築しようとしています。しかし、各 FQL クエリから結果が返されていないようです。これが私のコードで、さまざまなチュートリアル テンプレートからまとめられています。

<html>
<title>Testing Facebook Javascript SDK</title>
<body>
<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        // init the FB JS SDK
        FB.init({
            appId      : 'MY_APP_ID', // App ID from the App Dashboard
        channelUrl: '//www.myurl.net/channel.html',
            status     : true, // check the login status upon init?
            cookie     : true, // set sessions cookies to allow your server to access the session?
            xfbml      : true  // parse XFBML tags on this page?
        });

    // Additional initialization code such as adding Event Listeners goes here
    FB.getLoginStatus(function(response){
        if (response.status === 'connected'){
            showMyFriends();
            FB.api('/me/permissions',function(response){
                console.log(response);
            });
        } else if (response.status === 'not_authorized'){
            login();
        } else {
            login();
        }
    });


    };
    function login(){
        FB.login(function(response){
            if (response.authResponse){
                alert('login');
            } else {
                alert('cancelled'); 
            }
        },{scope:'read_stream'});

    }

    function showMyFriends(){
        FB.api('/me/friends',function(response){
            if(response.data){
                var length = response.data.length;
                for(var i=0;i<50;i++){
                    element=response.data[i];
                    getAFriendStatus(element.id);
                }
            }
        });
    }

    function getAFriendStatus(friendUID){
        FB.api('/fql',{q:{"query1":"select message from status where uid="+friendUID}},
            function(response){
                console.log(response);
            }
        );
    }



  // Load the SDK's source Asynchronously
  // Note that the debug version is being actively developed and might 
  // contain some type checks that are overly strict. 
  // Please report such bugs using the bugs tool.
  (function(d, debug){
     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 = "https://connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
     ref.parentNode.insertBefore(js, ref);
   }(document, /*debug*/ false));
</script>
</body>

コンソールを確認すると、呼び出しごとに得られるのgetAFriendStatus()は次のとおりです。

Object {data: Array[1]}
data: Array[1]
0: Object
fql_result_set: Array[0]
name: "query1"
__proto__: Object
length: 1
__proto__: Array[0]
__proto__: Object

のサイズが 0 であるためfql_result_set、クエリに問題があると思います。FB.api('/me/permissions')のコンソール出力は次のとおりであるため、権限の問題ではないと思います。

Object {data: Array[1], paging: Object}
data: Array[1]
0: Object
basic_info: 1
installed: 1
read_stream: 1

だから私はread_stream許可を得ていることを知っています。このクエリでステータスを取得できないのはなぜですか?

編集:FQLクエリを試してみました

"select message from status where uid=me()"

そして、最近のステータス投稿をすべて取得しました。友達のステータスを取得するだけの問題のようですか?これは、プライバシー設定が原因でしょうか?

4

1 に答える 1

0

これは私にとってはうまくいきます、私は使用しています

select message from status where uid = XXX

これにより、Graph API を使用した場合と同じ結果が得られます

XXX?fields=statuses

「 」のみを要求しているread_streamため、フレンド情報の権限も追加する必要があります。あなたが求める必要がある追加の許可は

friends_status

それがなければ、あなたは友達のUIDを取得するだけです

于 2013-07-05T07:41:38.217 に答える