0

我正在使用这段代码:

function newInvite(){
        var user_ids = document.getElementsByName("user_ids")[0].value;
        FB.ui({method: 'apprequests',
          message: 'My Great Request',
          to: user_ids, 
        });
      }

我需要存储从这个函数获得的请求 ID

function loadFriends()
{
    //get array of friends
    FB.api('/me/friends?fields=name,first_name,gender', function(response) {
        console.log(response);
        var divContainer=$('.facebook-friends');
                         var testdiv = document.getElementById("test");

for(var i=0; i<response.data.length; i++){
    if(response.data[i].gender == 'male'){
         testdiv.innerHTML += response.data[i].id + '<br />';
    }
}
    });
}

我该怎么做?

4

1 回答 1

0

是的,很简单,

        FB.ui({method: 'apprequests',
          message: 'My Great Request',
          to: user_ids, 
        }, requestCallback);

来源:请求对话框

[编辑]

function newInvite(users){
    FB.ui({method: 'apprequests',
      message: 'My Great Request',
      to: users.join(',')
    });
}

function loadFriends()
{
    //get array of friends
    FB.api('/me/friends?fields=name,first_name,gender', function(response) {
        console.log(response);
        var divContainer=$('.facebook-friends');
        var testdiv = document.getElementById("test");

        var  users = [];
        for(var i=0; i<response.data.length; i++){
            if(response.data[i].gender == 'male'){
                testdiv.innerHTML += response.data[i].id + '<br />';
            }
            users.push(response.data[i].id);
        }

        console.log(users)
        newInvite(users);        


    });
}
于 2012-05-28T11:32:01.070 回答