Take profile photo from facebook and save it to my database?

0

I'm already able to login with facebook but I do not get the person's photo, how do I do that?

I saw some things like '' link

But how can I use this?

    
asked by anonymous 14.09.2016 / 16:44

1 answer

0

I did this:

               FB.getLoginStatus(function(response){
                    if(response.status == 'connected') {
                        FB.ui(obj, callback);
                    }
                    else {
                        FB.login(function(response){
                            if(response.status == 'connected') {
                                //Depois do login chamo o callback
                                FB.ui(obj, callback);
                            }
                        });
                    }
                });
                //Função do callback                    
                function callback(response) {
                    if(response.error_code == 4201)
                    {

                    }
                    else
                    {
                        //Como no post_id retornado vem a {id}_{post_id}, eu dou um split e pego a ID.
                        var ids = response['post_id'].split('_');
                        //Como eu usei o angular, fiz os comandos abaixo, mas se quiser apenas a id -> ids[0];
                        var appElement = document.querySelector('[ng-controller=FbController]');
                        var $scope = angular.element(appElement).scope();
                        $scope.$apply(function() {
                            $scope.addJson(ids[0]);
                        });
                    }
                }

To get the photo I used the http://graph.facebook.com/v2.6/{{id}}/picture API

    
14.09.2016 / 16:59