Chris Jones
asked on
list friends list using the Facebook java SDK
Hello,
I am looking for some basic help i am trying to pull friends names from a user using the facebook javascript Graph API.
here is the function that I have
I am looking for some basic help i am trying to pull friends names from a user using the facebook javascript Graph API.
here is the function that I have
function friendslist()
{
console.log("Made it to friends list");
/* make the API call */
FB.api("/{friend-list-id}",
function (response) {
if (response && !response.error) {
console.log(response.id);
document.getElementById('status').innerHTML = response.id ;
}
}
);
ASKER
Hello,
i just tested the code and added a few debug lines and noticed it's only getting to this line and nothing after.
i just tested the code and added a few debug lines and noticed it's only getting to this line and nothing after.
if (response && !response.error)
Ok good job sir, let us now check the response content before the if statement like :
console.log( response );
ASKER
hmm looking at the error now let me know if you have any insight it may be a permission issue.
(#803) Some of the aliases you requested do not exist: {user-id}
aaah, you should replace the expression {user-id} by the real id of the user you want to get the list of his friends.
ASKER
getting closer I passed in the user's ID but I think the call is expecting something else
error: {message: "(#803) Some of the aliases you requested do not exist: {10156781396921240}", type: "OAuthException", code: 803, fbtrace_id: "EvfQq6RkO5B"}
__proto__: Object
ASKER
i even passed in the access token and it doe snot like that value as well
Make sure the access_token isn't expired and share with us the response when you pass it.
ASKER
here is the response from the code with the access token passed in.
update function
{error: {…}}error: {message: "(#803) Some of the aliases you requested do not ex…ZAuYoUKUx8vZCI1upOMihUF2U5csKwdUOwT0FvFeQyfwZDZD}", type: "OAuthException", code: 803, fbtrace_id: "Cq3sszJeg6D"}__proto__: constructor: ƒ Object()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()
update function
function friendslist(UserID, AT)
{
FB.api("/{"+ AT +"}/friends",
function (response) {
console.log(UserID);
console.log(AT);
console.log('friends list function start');
console.log( response );
if (response && !response.error)
{
console.log('If response in friends function');
for ( k in response.data ){
console.log( response.data[k].id, response.data[k].name );
}
}
}
);
}
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
Then loop through the data like :
Open in new window
The full script will be :
Open in new window