angularjs facebook-login fetch user data -
i working on angularjs , create login facebook using https://github.com/ciul/angular-facebook module. i'm unable fetch user data after login:
my controller is:
$scope.facebooklogin = function () { var promise = authenticationservices.fblogin(); promise.then( function(data){ console.log(data); }, function(error){ utilityservices.showtoast('error', 'unable connect facebook'); }); };
my services is:
this.fblogin = function() { $('.btn-disable').addclass('disabled'); facebook.login(function(response) { if(response.status === "connected") { console.log(response.authresponse); facebook.api('/me', function(response) { if(!response || response.error) { deferred.reject('error occured'); } else { deferred.resolve(response); } } ); } else { $('.btn-disable').removeclass('disabled'); } },{ auth_type: 'rerequest', scope: 'user_likes, email, user_friends' }); return deferred.promise; };
now want fetch user data set in scope id , name show in image below: app access follwing permission data doesnt available
you need specify fields now:
facebook.api('/me?fields=email,name,id', ...
for getting likes, there endpoint: /me/likes
...or can add in fields parameter too:
facebook.api('/me?fields=email,name,id,likes', ...
Comments
Post a Comment