Here is what I am working with, I have simplified it a little:
if (response.authResponse) {
FB.api('/me', function(response) {
response.id;
user_id = response.id; // I thought I could at least access it below if it was defined globally...
});
var friend_list = [];
FB.api('/me/friends', function(response) {
$.each(response.data,function(index,friend) {
friend_list.push(friend.id);
});
user_friend_list = friend_list.toString();
});
alert("user id:"+user_id+"friend list:"+user_friend_list); // Here is where I would like these two variables to show up
} else {
//user cancelled login or did not grant authorization
}
probably for some obvious reason (due to my poor javascript and jquery) I cannot capture the variables. If you provide an answer please explain a little so I can gain insight and learn.
Try this.
Altered bits and pieces of code. Comment if you have a problem with this solution.