I want to store the user id from FB.api into a global variable that I can use in other functions… how do I do this? I have the following code but it doesnt work…
var fbuserId;
function getFbid() {
FB.api('/me', function(response) {
fbuserId = response.id;
});
return fbuserId;
}
params.fbuid = getFbid(); // calling the getFbid() to return the variable, but returns nothing
Hi,
I have no idea what “Fb.api” is; however…
- have you tried placing alert messages in your functions to see if you are getting in, what values are being sent, received?
FB.api(‘/me’, function(response) {
FB.api(“\/me”,…
FB.api is a method for Facebook Graph api… but the problem I guess is more related to storing variables from within functions
I have tried to do the alert inside the function and it outputs the correct data, but when I try to store the data in the global variable fbuserId for some reason it aint working