How can I get facebook photo with selection view user set (if they use large image). If I use type = "large" or "normal" or "small" in path graph then I get image but It's not square and It's not selection view of user set. So, how can I get photo with square type and it's view of user set
You can get a square picture of higher dimensions than the normal one for type=square
(which will be only 50x50 pixels in size) by requesting a picture with width
and height
parameters set.
See https://developers.facebook.com/docs/reference/api/user/, “picture” connection, quote:
“Additionally, you can specify width and height URL parameters to request a picture of a specific size. This will return an available profile picture closest to the requested size and requested aspect ratio. […] if width=height, we will always return a square picture.”
Example:
https://graph.facebook.com/4/picture?type=square – Mr Zuckerberg’s “normal” square profile pic, size 50x50
https://graph.facebook.com/4/picture?width=100&height=100 – 100x100 pixels, perfect match for requested size
https://graph.facebook.com/4/picture?width=150&height=150 – asking for 150x150, getting 156x156 instead.
If you can live with maybe sometimes getting images that might be a little bigger (or smaller) then the requested size, you should be fine.
Otherwise it’ll take some testing to try and figure out if there are certain square image sizes that Facebook will always have “in stock” and deliver exact matches for, or if it might differ for every user depending on the picture they uploaded.
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{ @"fields" : @"id,name,picture.width(100).height(100)"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
}
instead of 100 you can put 200 ,300 encrypt the response and get it with key
Try using the type square
. As follows:
http://graph.facebook.com/[user_id]/picture?type=square
The square size is limited to 50x50. If you want a large size, you will have to enlarge the square version or crop the large version.
If you don't mind retrieving and cropping an image yourself, follow my tutorial here for code to do exactly that. It will let you generate square images larger than 50px.
This worked for me. Check the following query,
NSString * graphPath = [NSString stringWithFormat:@"%@?fields=photos.fields(id,link,source)", albumID];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With