I am facing a challenge with angularjs.
I am trying to retrieve values within the Facebook SDK functions but I am unable to store them in variables.
The perfil_nombre
and perfil_foto
variables are returning as "undefined" and I need to assign them to the scope.
Is there any solution? I am completely lost.
login.controller('inicio_ctrl', function($scope, $http, $timeout, $window)
{
var laspaginas;
var response;
var perfil_foto;
var perfil_nombre;
var resp;
$scope.FBLogin = function()
{
FB.login(function(response)
{
if(response.authResponse)
{
FB.api('/me', function(response)
{
perfil_nombre = response.name; //<<<<<-------- good
FB.api('/me/picture?redirect=false', function(resp)
{
perfil_foto = resp.data.url; //<<<<<-------- good
});
});
}
else
{
console.log('User cancelled login or did not fully authorize.');
}
},
{ scope: 'email, public_profile, manage_pages,publish_pages,read_insights,user_friends, publish_actions'});
$scope.perfil_foto = perfil_foto; //<<<<<-------- undefined
$scope.perfil_nombre = perfil_nombre; //<<<<<-------- undefined
});