0

I have tried several ways to get larger images from Facebook Graph API, but I have not succeeded.

  1. I don't really know how this Parameters work. So will you explain me that too?
  2. Also I need to know how to grab the larger images. I first get the album I'd and then pictures ID and then I fetch the image of the album.
  3. What is the best picture size to get for iPhone 6?

    let parameters = ["fields": "picture.height(400).width(200)"]
    FBSDKGraphRequest(graphPath: "/{picture-id}", parameters: parametes, HTTPMethod: "GET")
    
user2884707bond
  • 559
  • 4
  • 24

4 Answers4

1

If the picture you get with picture?type=large is not big enough, I suggest you try with picture?width=9999 for example.

The code would be:

let requestPicture = FBSDKGraphRequest(graphPath: "{user_id}/picture?width=9999&redirect=false", parameters: nil, HTTPMethod: "GET")

This SO thread may be useful to you regarding parameters.

Community
  • 1
  • 1
Nikola Milicevic
  • 2,886
  • 3
  • 17
  • 17
  • Thanks, I can't believe that the large image is 200x200. I don't think anyone would refer to that as large. – Rob Nov 10 '17 at 23:20
0

If you already have the user's ID and they have given appropriate permissions, you can do:

let imageUrl = NSURL(string: "https://graph.facebook.com/\(userId)/picture?type=large")
  if let data = NSData(contentsOfURL: imageUrl!) {
        let profilePicture = UIImage(data: data)
  }
}

You can also do any of the enum values: small, normal, album, large, square as explained here. Better yet, you can use AFNetworking to load the image in the background with a placeholder image, which handles caching and everything for you. See here for more details, specifically setImageWithURL.

Vanessa Forney
  • 436
  • 5
  • 7
  • Oh this is good useful information. Thank you. Can you explain more about parameter? And I am looking for album larger picture? – user2884707bond Mar 30 '16 at 04:54
0

From the login or by making the basic graph request with me you can get user-id and from that user-id you may try this

You can try like this:

let fbRequest = FBSDKGraphRequest(graphPath:"/{user-id}/picture?redirect=false&type=large", parameters: nil);
                    fbRequest.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!) -> Void in
                        if error == nil {

                            print("Result is : \(result)")
                            /* this will return the data of the image which you can use with imageview with data method {
                              "data": "ProfilePictureSource",
                               "paging": {}
                            }*/

                        } else {

                            println("Error Getting Friends \(error)");

                        }
          }

For the fields which you have pass picture.height and picture.width is used to specify the image with which is return to you in the response

You can use both types of size reference :

Predefined sizes: small, normal, large, square.
Custom size: specify the width and height of the image you want

For more information you can check the facebook doc : Facebook doc:User Profile

HardikDG
  • 5,892
  • 2
  • 26
  • 55
0

You can use Graph API to get different size of images. You need to have picture id. You request it like this:

/{picture-id}?fields=width,height,images

Since above query returns JSON data. In that data "images" contains different sizes.

user2884707bond
  • 559
  • 4
  • 24