Guy
Guy

Reputation: 107

Graph API changes for the picture

Using the FB iOS sdk, I am facing an issue in the retrieval of pictures with the Graph API.

I used to do [facebook requestWithGraphPath:@"me?fields=id,first_name,last_name,picture,gender,email&type=large" andDelegate:self];

to retrieve the informations about the signed in user. It still works except that the picture used to be the large one, now it's the small one.

I DON'T want to call the picture request separately, otherwise I wouldn't be posting here.

Any hint on how can I have the old results back ? The bio data + the large picture in one request.

Thx for the help.

Upvotes: 2

Views: 439

Answers (3)

King-Wizard
King-Wizard

Reputation: 15694

Answer to the question in Swift (old and new Facebook URI(s) syntaxes):

enum FacebookEndPoint: String {
    case Me = "me"

    static func userProfilePicture(let facebookID: String, let pictureType: String) -> String {
          // Old syntax
          // return "/\(facebookID)/picture?type=\(pictureType)"

          // New syntax
          return "/\(facebookID)?fields=picture.type(\(pictureType))"
    }

    static func userProfilePicture(let facebookID: String, let width: Int, let height: Int) -> String {
        // Old syntax
        // return "/\(facebookID)/picture?width=\(width)&height=\(height)"

        // New syntax
        return "/\(facebookID)?fields=picture.width(\(width)).height(\(height))"
    }
}

Note: I just tested the URI(s) through the Facebook Graph Explorer tool and both syntaxes (the old and new one) work at the time where I am writing this answer.

Upvotes: 0

Jan S.
Jan S.

Reputation: 10348

I have found that picture.type(large) does not return a square picture. If you want a larger picture but keep it square you can use width and height set to the same value, like this:

picture.width(200).height(200)

Upvotes: 2

Suhail Patel
Suhail Patel

Reputation: 13694

Instead of requesting picture, try requesting the large picture type using picture.type(large) so your request looks something like this:

[facebook requestWithGraphPath:@"me?fields=id,first_name,last_name,picture.type(large),gender,email" andDelegate:self];

This will return a value as picture in the response but it will have the large image URL rather than the small image URL

Upvotes: 4

Related Questions