0

I have been looking around online at how to post a UIImage to the users Facebook wall using the Facebook SDK. However I'm really confused what the simplest option is. So far I have only used the Facebook SDK to create a connection and post a message to the wall like so:

// Create message
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"Blah", @"name",
                                   @"", @"caption",
                                   @"", @"description",
                                   @"http://www.xyz.com", @"link",
                                   @"", @"picture",   // THIS IS NOT BIG ENOUGH
                                   nil];

// Post it to the users feed
[facebook dialog:@"feed" andParams:params andDelegate:nil];

This seems to work nicely and allows me to upload a short amount of text as well as an image. The issue I'm having is that the image is far too small. I need a way of allowing the user to upload a larger (in terms of viewing size) image as well as a short caption.

Please can someone offer a solution (ideally that could work off my existing code)?

  • by larger image do you mean in terms of resolution .. ? – Aatish Molasi May 16 '12 at 14:20
  • I'm not fully sure of the technical terms but I need the image to be big in terms of viewing size...maybe 400x400 px (or there abouts) –  May 16 '12 at 14:22
  • 1
    check my answer [here](http://stackoverflow.com/questions/10024056/uploading-uimage-to-facebook/10024612#10024612) – Malek_Jundi May 16 '12 at 14:28
  • the image is uploaded based on the size that it is in your application .. you would have to scale the image within your application if you want it to be larger http://stackoverflow.com/questions/2645768/uiimage-resize-scale-proportion – Aatish Molasi May 16 '12 at 14:29
  • @Malek_Jundi Thanks for your solution, I have one other question. How can I add a caption to the uploaded image? –  May 16 '12 at 15:05
  • 1
    @TheCrazyChimp send it as string with the parameters under @"message" key .. and don't forget to up-vote my answer :) – Malek_Jundi May 16 '12 at 15:09

1 Answers1

2

I managed to achieve this thanks to @Malek_Jundi. Here is the code I used:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:[facebook accessToken], @"access_token",nil];
[params setObject:@"Caption to go with image" forKey:@"name"];
[params setObject:myImage forKey:@"source"];   // myImage is the UIImage to upload
[facebook requestWithGraphPath:@"me/photos"
                     andParams: params
                 andHttpMethod: @"POST"
                   andDelegate:(id)self];
  • that's a fine solution! maybe you want to take a look at [BMSocialShare](http://github.com/blockhaus/BMSocialShare) as well for sharing :) – vinzenzweber May 17 '12 at 15:05