친구의 이름을 얻을 수 있습니다 :어떻게이 코드를 사용하고
function login() {
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me/friends', {
fields: 'id,name'
}, function(response) {
for (element in response) {
console.log(element.name);
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {
'scope': 'user_friends'
});
}
을하지만 콘솔이 응답을 얻을 :
Welcome! Fetching your information....
2 undefined
왜?
편집 : 난 그냥 위의 코드 편집 한
:
function login() {
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me/friends', {
fields: 'id,name'
}, function(response) {
console.log(response.summary);
console.log(response);
for (element in response.data) {
console.log(element.id);
}
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {
'scope': 'user_friends'
});
}
하지만 지금이 응답을 얻을 :
Welcome! Fetching your information....
Object {total_count: 58}
Object {data: Array[0], summary: Object}
입니다
이 올바른 코드 것입니까? – WizKid
@WizKid가 응답과 함께 질문을 편집했습니다. – xRobot
응답이 정확합니다. 아직 친구를 승인 한 친구가 없습니다. – luschn