Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FacebookService($http, config) {
- this.getUserPicture = function(userId, token) {
- return $http({
- method: 'GET',
- url: 'https://graph.facebook.com/' + userId + '/picture?type=large&redirect=false'
- })
- }
- }
- function HomeController($scope, $cordovaNativeStorage, FacebookService, $ionicLoading) {
- if (window.cordova) {
- // Get Facebook access token
- $cordovaNativeStorage.getItem("facebookAccessToken").then(function(value) {
- $scope.facebookAccessToken = value
- // 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
- FacebookService.getUserPicture($scope.facebookUserData.id).then(function(dataResponse) {
- $scope.facebookUserPicture = dataResponse.data;
- // Save Facebook user picture
- $cordovaNativeStorage.setItem("facebookUserPicture", $scope.facebookUserPicture).then(function() {}, function(error) {
- console.error("Unable to cache user data: " + result);
- $ionicLoading.show({
- template: 'Unable to cache user data',
- duration: 1500
- })
- });
- }, function(error) {
- console.log(error.data.error.message)
- })
- }, function(error) {
- console.log(error.data.error.message)
- })
- }
- };
- <img class="icon icon-home img-circle" ng-src="{{ facebookUserPicture.data.url }}">
Add Comment
Please, Sign In to add comment