Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBRequest: Why aren't non-text mime type responses allowed? (iOS SDK)

Using the Facebook iOS SDK, let's say I perform a graph request for the user's profile picture:

[FBRequest requestForGraphPath:@"me/picture"]

I'll receive this error:

Response is a non-text MIME type; endpoints that return images and other binary data should be fetched using `NSURLRequest` and `NSURLConnection`.

What is the reasoning behind this? It only took a minute to write the request manually but why isn't this common task included in the Facebook iOS SDK or am I missing something?

Looking through the Facebook iOS SDK repo on Github, we see this in 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"];
    }

If I'm understanding this correctly, FBRequestConnection gets the response I want (i.e. the profile image) and THEN tells me I can't have it. What a tease. Why make the request in the first place?

Any comments on this?

like image 251
Chris Avatar asked Oct 19 '12 02:10

Chris


1 Answers

For large picture

me?fields=picture.type(large)

Refer to Facebook Graph API Change: Picture type (size) no longer working?

like image 67
Evan Lin Avatar answered Sep 27 '22 20:09

Evan Lin