-1

Facebookで友達の名前とIDを返す関数があります。後でアクセスするために、それらを配列に格納するのに助けが必要です。何か案は?

//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");
        }
    });
}
4

1 に答える 1

2

この行を置き換えます:

console.log(friend.name + ' has id:' + friend.id);

このようなもので:

friends.push({'name' : friend.name, 'id' : friend.id});

基本的には応答データを調べて再構築しているように見えますが、おそらく各友人から余分なデータをいくつか捨てていますか?

于 2012-07-05T13:55:37.743 に答える