Thank you for your reply. I already take the permission access token to list the friends and friend of friend. Now I have taken the list using script. But I need the friends id or name with the corresponding and want to save the same to my database. Can you suggest me a solution. My code is as shown below.
function Friendslist() {
// First get the list of friends for this user with the Graph API
FB.api('/me/friends', function (response) {
var container = document.getElementById('relatn');
var container1 = document.getElementById('frnd');
var container3 = document.getElementById('nn');
var mfsForm = document.createElement('form');
mfsForm.id = 'mfsForm';
var mfsForm2 = document.createElement('form2');
mfsForm2.id = 'mfsForm2';
// Iterate through the array of friends object and create a checkbox for each one.
for (var i = 0; i < Math.min(response.data.length, 300); i++) {
var friendItem = document.createElement('div');
friendItem.id = 'friend_' + response.data[i].id;
friendItem.innerHTML = '<input type="label" name="friends" value="'
+ response.data[i].id
+ '" />' + response.data[i].name;
mfsForm.appendChild(friendItem);
var id = response.data[i].id;
var username = response.data[i].name;
// var headName = document.createElement('div');
// headName.id = 'friend_' + response.data[i].id;
// headName.innerHTML = '<b><input type="label" name="friends1" value=' + username + '/></b>';
// mfsForm2.appendChild(headName);
// container3.appendChild(mfsForm2);
FB.api('/' + id + '/friends', function (response) {
var container2 = document.getElementById('f1');
var mfsForm1 = document.createElement('form1');
mfsForm1.id = 'mfsForm1';
// Iterate through the array of friends object and create a checkbox for each one.
for (var i = 0; i < Math.min(response.data.length, 300); i++) {
// alert(response.data.length);
while (response.data.length) {
var friendItem1 = document.createElement('div1');
friendItem1.id = 'friend_' + response.data[i].id;
friendItem1.innerHTML = '<input type="label" name="friends1" value="'
+ response.data[i].id
+ id
+ '" />' + response.data[i].name + "<br />";
mfsForm1.appendChild(friendItem1);
}
alert("stop");
}
container2.appendChild(mfsForm1);
});
}
container.appendChild(mfsForm);
// Create a button to send the Request(s)
var sendButton = document.createElement('input');
sendButton.type = 'button';
sendButton.value = 'Send Request';
sendButton.onclick = sendRequest;
mfsForm.appendChild(sendButton);
});
}