I am trying to get a ID and NAME of User's FRIEND by random with this code:
// Acess Grantes of permissions code (not full (work))
function checkPerms(){
var permsNeeded = ['email','public_profile','user_friends'];
//.... Continue of CheckPerms ( it works fine)
// this is User's Friend ID random ( no work)
FB.api(
"/{user-id}/friends",
function (response) {
if (response && !response.error) {
var random = Math.floor(Math.random()*response.data.length);
console.log(random);
/* handle the result */
}
}
);
// this is user NAME (work)
FB.api("/me", function(res){
uname = (res.name)?res.name : '';
console.log(uname);
});
// This is User Friend's NAME ( no work)
FB.api("/"+uid1, function(res){
fname = (res.name)?res.name : '';
console.log(fname);
});
I only get console of uname, not others. can you please tell me what's wrong in my code / or if I need any permission from facebook to acess the data of friend ID's and names.