I have a function that returns the names and id’s of my friends on facebook. I need help in storing them in an array for accessing them later. Any ideas?
//using JQuery
function getFriends() {
alert(" ok lets try and retrieve some friends ");
FB.api('/me/friends', function (response) {
if (response.data) {
alert("waiting for the buddies list");
$.each(response.data, function (index, friend) {
console.log(friend.name + ' has id:' + friend.id);
});
} else {
alert("Unable to retrieve friends' list");
}
});
}
Replace this line:
With something like this:
Although it looks like you’re basically just running through the response data and rebuilding it, perhaps tossing out some extra data from each friend?