使用Facebook iOS SDK,假设我为用户的个人资料图片执行图形请求:
[FBRequest requestForGraphPath:@"me/picture"]
我会收到此错误:
Response is a non-text MIME type; endpoints that return images and other binary data should be fetched using `NSURLRequest` and `NSURLConnection`.
这背后的原因是什么?手动编写请求只需要一分钟,但为什么这个常见任务不包含在Facebook iOS SDK中,或者我错过了什么?
通过Github上的Facebook iOS SDK回购,我们在FBRequestConnection.m
中看到了这一点:
if (!error && [response.MIMEType hasPrefix:@"image"]) {
error = [self errorWithCode:FBErrorNonTextMimeTypeReturned
statusCode:0
parsedJSONResponse:nil
innerError:nil
message:@"Response is a non-text MIME type; endpoints that return images and other "
@"binary data should be fetched using NSURLRequest and NSURLConnection"];
}
如果我正确理解这一点,FBRequestConnection
会得到我想要的回复(即个人资料图片),然后告诉我我不能拥有它。多么可爱啊。为什么要首先提出请求?
对此有何评论?
答案 0 :(得分:5)
大图片
me?fields=picture.type(large)
请参阅Facebook Graph API Change: Picture type (size) no longer working?
答案 1 :(得分:1)
解决方案是要求特定字段而不是图片(在此处找到:Facebook Graph API will not give me picture data)
所以使用
[FBRequest requestForGraphPath:@"me?fields=picture"]
那应该有用