图片API更改图片

时间:2012-09-13 08:31:39

标签: ios facebook size image

使用FB iOS sdk,我在使用Graph API检索图片时遇到了问题。

我曾经做过[facebook requestWithGraphPath:@"me?fields=id,first_name,last_name,picture,gender,email&type=large" andDelegate:self];

检索有关已登录用户的信息。它仍然有效,除了图片曾经很大,现在它是小图片。

不要想要单独调用图片请求,否则我不会在这里发帖。

有关如何获得旧结果的任何提示?生物数据+一张请求中的大图片。

请求帮助。

3 个答案:

答案 0 :(得分:4)

请尝试使用picture请求大图片类型,而不是请求picture.type(large),因此您的请求如下所示:

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

这将在响应中返回一个值作为图片,但它将包含较大的图片网址而不是小图片网址

答案 1 :(得分:2)

我发现picture.type(large)不返回方形图片。如果你想要一个更大的图片,但保持方形,你可以使用宽度和高度设置为相同的值,如下所示:

picture.width(200).height(200)

答案 2 :(得分:0)

回答 Swift Facebook URI(s)语法)中的问题:< / p>

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))"
    }
}

注意:我刚刚通过Facebook Graph Explorer工具测试了URI,两种语法(旧的和新的)都在我写这个答案的时候工作。