Reputation: 4431
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
Upvotes: 24
Views: 38539
Reputation: 579
[[[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
Upvotes: 12
Reputation: 96151
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.
Upvotes: 48
Reputation: 1530
This worked for me. Check the following query,
NSString * graphPath = [NSString stringWithFormat:@"%@?fields=photos.fields(id,link,source)", albumID];
Upvotes: 2
Reputation: 12072
Get the photo by querying for the user's profile data using FQL. In your case you shouldn't need any access token. There is a column called pic_crop
which is an object that contains the uri you need:
The URL to the largest-sized square profile picture for the object being queried.
width
,height
: the pixel dimensions of this picture.left
,top
,right
,bottom
: the pixel co-ordinates of the user selected crop for this profile picture.
Use the Graph API Explorer for testing your query.
Update: From the Facebook Query Language (FQL) Reference:
Version 2.0 of the Facebook Platform API is the last version where FQL will be available. Versions after 2.0 will not support FQL. Please migrate your applications to use Graph API instead of FQL. Please see our changelog for current version information.
Upvotes: 1
Reputation: 15457
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.
Upvotes: 3