Cómo obtener fotos de perfil de amigos usando la consulta FQL usando FBGraph-API

I would like to know do I have an option to set pics width and height while requesting. Somebody suggested me to use the below query to achieve this behavior:

SELECT id, width, height, url, is_silhouette, real_width, real_height FROM profile_pic
 WHERE id=me() AND width=155 AND height=50

Is this the correct process? According to my requirement I need to display profile pics in a table as in the attached screenshot with 155 as width and 50 as height.

My Friends List

Gracias de antemano

preguntado el 05 de septiembre de 12 a las 10:09

6 Respuestas

FQL to get list of facebook friends information & their Pics

NSString *query = @"SELECT uid,name,first_name,last_name,pic_square FROM user WHERE uid IN (";
query = [query stringByAppendingFormat:@"SELECT uid2 FROM friend WHERE uid1 = %@)",userid];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                query, @"query",
[_facebook requestWithMethodName: @"fql.query" 
                       andParams: params
                   andHttpMethod: @"POST" 

You will get responce in follwing method

  -(void)request:(FBRequest *)request didLoad:(id)result 

Por ejemplo

    "first_name" =User;
    "last_name" = R;
    name = "User R";
    "pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/.jpg";
    uid = 595sd1;
 {},{} etc

¡Espero que esto ayude!

Otra forma es

Obtenga la identificación (o el nick) del usuario y obtenga la imagen de https://graph.facebook.com/idOrNick/picture

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture", id]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
UIImageView *imgView = [[UIImageView alloc]init];
imgView.image = image;

And for size

PICTURE SIZES: square (50×50)

small (50 pixels wide, variable height)

grande (aproximadamente 200 píxeles de ancho, altura variable)

and for applying this type of size you have to append it end of the URL

por ejemplo

http://graph.facebook.com/"id or Nick"/picture?type=large. [small/square/large]

Respondido el 05 de Septiembre de 12 a las 12:09

femina : I am using FBGraphAPI, and what is the variable _facebook - iYahoo

I need to know how can i set its width and height - iYahoo

_facebook is object of Facebook Class. - Glotón

For setting pics width and height while requesting......i have no idea.....but From above answer you can have image and then you can resize Image. - Glotón

femina : i am using FBGraphAPI, so, i am not using facebook class, do we have any alternative for that ??? - iYahoo

Use the Graph API field expansion approach -


Respondido el 12 de Septiembre de 12 a las 22:09

I have tried this way, when i am giving this way i am getting image width as 0.00 and height also 0.00 - iYahoo

I'm looking for the answer to this question, too. Finally I think this call is the best:


You can also replace the 'me' with a certain id.

respondido 08 mar '13, 18:03

Según los documentos https://developers.facebook.com/docs/reference/api/using-pictures/ , there is a simpler way to do it. The direct URL to get customized image from facebook is:


I understand the question is about using GraphAPI to get the URL but why make one extra call when you can give the image src URL directly.

<img src="https://graph.facebook.com/${ID}/picture?width=${customwidth}&height=$customheight" />

contestado el 24 de mayo de 13 a las 15:05

Here is a code , which can help you to get friend's profile picture.

  1. Get the Id of a friend from the FBGraph API e.g

     NSString *id = @"505326797";
  2. Then paste the following code ...

     NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture",id]];
  3. This is the way you can get the exact url of friend's picture ,, use this either in Asynchronous Image View or somewhere else.....

Perhaps it will help you...

Respondido 25 ago 15, 13:08

I am getting the friends Profile picture, but i want to know how can i set the friends profile pic width and height - iYahoo

You can set the imageView width/Height , but your image will be stretched then.... - Khalid Usman

thats why i would like to want without streching, we want to give the width and height previously - iYahoo

Yes. Your code is correct. This will get version of your picture that is approx. 155 x 50px.

If you wanted to get a user's friend's pictures, use esta consulta:

 SELECT id, width, height, url, is_silhouette, real_width, real_height  
     FROM profile_pic
         WHERE id IN (SELECT uid1 FROM friend WHERE uid2=me()) AND width=155 AND height=50

Respondido 25 ago 15, 13:08

thank u for the answer, but i would like to know How can i send that Query to facebook, i am using FBGraphAPI, where i am not having requestWithMethodName, requestWithDelegate, - iYahoo

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.