FBRequest: Why are non-text mime responses not allowed? (IOS SDK)

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

[FBRequest requestForGraphPath:@"me/picture"] 

I will get 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 reason for this? It only takes a minute to write a request manually, but why is this common task not included in the SDK for iOS Facebook or am I missing something?

Looking through the Facebook iOS SDK repository 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 understand correctly, the FBRequestConnection receives the response that I want (i.e. the profile picture), and THEN tells me that I cannot receive it. Which tease. Why make a request in the first place?

Any comments on this?

+4
source share
2 answers

For large image

me?fields=picture.type(large)

Refer to Changing Facebook API: Does image type (size) no longer work?

+5
source

The solution is to request a specific field instead of an image (found here: Facebook Graph API will not give me image data )

Therefore use

 [FBRequest requestForGraphPath:@"me?fields=picture"] 

This should work

+1
source

Source: https://habr.com/ru/post/1440684/


All Articles