我打电话给 facebook fql 来获取一个组的所有成员。如果我在第一个函数中检查所有成员,它工作得很好,但是当我在第二个函数中调用它时,返回“未定义”。
function getAllMembers(groupid){
var allmembers = new Array();
var content = document.getElementById('content-text');
FB.api({
method: 'fql.query',
query: 'select uid from group_member where gid =' + groupid
},
function(resp){
for (var i=0, l= resp.length; i<l; i++)
{
allmembers[i] = resp[i].uid;
}
return allmembers;
}
)
}
function retrieveMessages(groupid){
var allmembers;
allmembers = getAllMembers(groupid);
console.log(allmembers);
}
I don't understand where's the mistake.