Fetch facebook large profile picture using Javascript SDK

While developing an facebook app – AWESOME PICS, I came to know that facebook doesn give access to the bigger profile picture of an user directly. I mean there is no easy way like http://graph.facebook.com//picture?type=large. Thus if you are working on an app which uses large pictures, you might fetch the larger profile pic in the following ways. I know its tedious. But as of now these are the only ways available.

I am using Javascript SDK here.

Using Graph API Method:

FB.api(‘/me/albums’, function (response)
for (album in response.data)
// Find the Profile Picture album
if (response.data[album].name == “Profile Pictures”)
// Get a list of all photos in that album.
FB.api(response.data[album].id + “/photos”, function(response)
//The image link
image = response.data[0].images[0].source;

Using FQL Method:

//get the current user id
FB.api(‘/me’, function (response)
// the FQL query: Get the link of the image, that is the first in the album “Profile pictures” of this user.
var query = FB.Data.query(‘select src_big from photo where pid in (select cover_pid from album where owner={0} and name=”Profile Pictures”)’, response.id);
query.wait(function (rows)
//the image link
image = rows[0].src_big;

and dont forget to add the required permissions. Because otherwise you wont get any error but empty results.

‘scope’         => ’email, — , — ,— , — ,user_hometown,user_photos‘,


3 thoughts on “Fetch facebook large profile picture using Javascript SDK

  1. The variable ‘image’ will have the source URL of the picture. So use it the way you want.
    Ideally you store it in an array and reuse it somewhere else.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s