简体   繁体   中英

How to post a UIImage to Facebook wall (iPhone/iPad)?

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)?

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM