Guest User

Untitled

a guest
Dec 3rd, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. function FacebookService($http, config) {
  2. this.getUserPicture = function(userId, token) {
  3. return $http({
  4. method: 'GET',
  5. url: 'https://graph.facebook.com/' + userId + '/picture?type=large&redirect=false'
  6. })
  7. }
  8. }
  9.  
  10. function HomeController($scope, $cordovaNativeStorage, FacebookService, $ionicLoading) {
  11. if (window.cordova) {
  12. // Get Facebook access token
  13. $cordovaNativeStorage.getItem("facebookAccessToken").then(function(value) {
  14. $scope.facebookAccessToken = value
  15.  
  16. // Get Facebook user picture (currently stored as a URL, would want to store it as a base 64 string which can be displayed as an image
  17. FacebookService.getUserPicture($scope.facebookUserData.id).then(function(dataResponse) {
  18. $scope.facebookUserPicture = dataResponse.data;
  19.  
  20. // Save Facebook user picture
  21. $cordovaNativeStorage.setItem("facebookUserPicture", $scope.facebookUserPicture).then(function() {}, function(error) {
  22. console.error("Unable to cache user data: " + result);
  23. $ionicLoading.show({
  24. template: 'Unable to cache user data',
  25. duration: 1500
  26. })
  27. });
  28. }, function(error) {
  29. console.log(error.data.error.message)
  30. })
  31. }, function(error) {
  32. console.log(error.data.error.message)
  33. })
  34. }
  35. };
  36.  
  37. <img class="icon icon-home img-circle" ng-src="{{ facebookUserPicture.data.url }}">
Add Comment
Please, Sign In to add comment