Search code examples
objective-ciosfacebookfacebook-ios-sdk

Uploading UIImage with FBDialog


I'd like to use the FBDialog from the Facebook SDK, but it seems like it only takes an URL for posting images. Is there any way to upload an UIImage to Facebook using the FBDialog without uploading the image to another server before posting?

I'm currently using this to post an UIImage on facebook:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"A caption", @"caption",
                               nil];
[_facebook requestWithMethodName:@"photos.upload" andParams:params andHttpMethod:@"POST" andDelegate:nil];

It works great, but I need the FBDialog . Is there any way to do same thing with the FBDialog?

Any help is appreciated.


Solution

  • No, to post a UIImage you cannot directly attach it. Here are two methods:

    1. Is too upload to a server and then take a URL/request/query to that server
    2. (A more practical approach) Upload to your Facebook user's album and then post that picture

    For more in-depth tutorial look at this link:

    Official Facebook iOS Tutorial

    This is a similar question with a great answer that provides step by step tutorial