Take a facebook profile picture and save it to my database?

Asked

Viewed 493 times

1

  • this he a json file he so vc parse with jquery or php to get the information q need

  • 1

    Avoid posting links to questions, post the code of what you have tried, or the information that is returned by a web service link for example. If you have questions on how to prepare your question, read this: http://answall.com/help/how-to-ask

1 answer

0

I did it this way:

               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 API http://graph.facebook.com/v2.6/{{id}}/picture

Browser other questions tagged

You are not signed in. Login or sign up in order to post.