Max Stern
Max Stern

Reputation: 23

Retrieving large profile picture using Facebook API v.2.1

I am using this jQuery plugin for facebook login.. https://github.com/ryandrewjohnson/jquery-fblogin

It is working fine except I am having issues with getting the large profile picture using this code.. here is my code:

 getFbFields: function (accessToken) {
    FB.api('/me', {fields: options.fields}, function(response) {
        if (response && !response.error) {
            $dfd.resolve(response);
        } 
        else {
            $dfd.reject(response);
        }
    });
}

and I have set the options this way

options.permissions = options.permissions || 'email';
options.fields = options.fields || 'picture,email,name';
options.success = options.success || function(){};
options.error = options.error || function(){};

Everything is working fine this way, except this code only gets me the smallest profile picture 50x50 px, what I want to get is a larger image 150x150 px or more and download it to my server via php.. I see that there is an option in facebook api v.2.1 to disable redirect and get large image, I just don't know how to implement it here..

I also tried the following code according the the api manual, but no luck:

FB.api(
"/me/picture",
    {
    "redirect": false,
    "height": "200",
    "type": "normal",
    "width": "200"
    },
    function (response) {
        if (response && !response.error) {
            $dfd.resolve(response);
        }
    }
);

Any help will be appreciated..

Thanks..

Upvotes: 2

Views: 870

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337743

You don't need to use the SDK to get the image. It is stored at the following URL:

http://graph.facebook.com/[FBID]/picture?type=large

You obviously would need to amend the [FBID] with the Facebook id of the user's image you're trying to retrieve.

Upvotes: 6

Related Questions