简体   繁体   English

如何将UIImage发布到Facebook墙(iPhone / iPad)?

[英]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 . 我一直在网上搜索如何使用Facebook SDKUIImage到用户Facebook墙上。 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: 到目前为止,我只使用Facebook SDK创建连接并将消息发布到墙上,如下所示:

// 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. 感谢@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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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