0

I am currently trying to get a list of friends who have added the same app via the FQL query. I am actually doing this for a school project, and apparently, the server where this is going to be saved is not supported via PHP.That is why i am using the JavaScript SDK to code this.

This is actually the first time that I am doing a project in Facebook and everything is extremely new to me and having the graph api is not helping with me with any old documentations at all since many things have been changed and documentation is very scarce >.<.

Currently, I am having problems displaying multiple results (i am only able to do so if i hard code the response)

I've tried using a for loop to print the result but to no avail.

FB.api('/me', function(response) {
showLoader(false);
var query       =  FB.Data.query('SELECT uid, name, pic_square FROM user WHERE uid 
IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user');

query.wait(function(rows) {



for(var i = 0; i< rows.length;i++)
{ 
document.getElementById('debug').innerHTML =              
''+ rows[i].name +"<br />" + "<img src=\""+ rows[i].pic_square +"\" /><br />";
}
  }); 

    });

am i doing this wrong in any way? >.<. Any help would be reallllly great!! Thanks!

4

1 に答える 1

0

多分それはあなたがデバッグdivに置いているものをステップオーバーしているという事実です。試す

document.getElementById('debug').innerHTML +=

また、forループは必要ありません。forEach関数を使用して、Facebookにそれを実行させることができます。

複数の結果が返されるようにするには、次のようにします。

var linkquery = FB.Data.query('select owner, owner_comment, url from link where owner={0}', response.id);
FB.Data.waitOn([linkquery], function() {
  FB.Array.forEach(linkquery.value, function(row) {
    document.getElementById('debug').innerHTML += 'FQL Information: '+  "<br />" + 
      'Your name: '      +  row.owner + "<br />" +
      'Your comment: '   +  row.owner_comment + "<br />" +
      'Your link: '      +  "<a href='" + row.url  + "'>" +  row.url  + "</a><br /><br />";
  });
});

FB.Array.forEachそれぞれrow.ownerを取得し、デバッグdivに追加されます-

document.getElementById('debug').innerHTML += 

返される各行で。

お役に立てば幸い

于 2012-02-06T22:36:12.823 に答える