First of all, you probably want to use a more efficient fql
query, such as
SELECT name, sex, uid FROM user WHERE uid in ( SELECT uid2 FROM friend WHERE uid1 = me() )
Simply pass this to graph.facebook.com/fql?q=SELECT%20%name....
Then, move the alert into the response handler, after you have completed summing up the numbers.
FB.api('/fql', {q: "SELECT name, sex, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me())"}, function (response) { if (response.data) { var genderCount = { male: 0, female: 0, unknown: 0 }; response.data.forEach(function (row) { genderCount[row.sex || 'unknown']++; }); alert(JSON.stringify(genderCount)); } });
resurrection masters tickets one direction tulsa news scalloped potatoes the ten commandments charlton heston
No comments:
Post a Comment