1

我想从我的 iphone 应用程序分享图像、链接等到 Facebook。我的应用程序链接、阳离子、名称和描述已成功发布。但我无法分享图像。请按照我的代码..

UIImage *image = [UIImage imageNamed:@"sample.png"];
NSData *imgData = UIImageJPEGRepresentation(image, 1.0);

self.dictionary =[[NSMutableDictionary alloc] initWithObjectsAndKeys:     @"https://www.google.com/ios", @"link",
 imgData, @"data",

 @"AppName", @"name",

 @"Testing", @"caption",

 @"say something about this", @"description",
 nil];

我的分享 facebook 代码是..

[facebook requestWithGraphPath:@"/me/feed" andParams:dictionary andHttpMethod:@"POST" andDelegate:self];

我的问题是如何从捆绑包中获取图像以及如何将选定的图像分享到 Facebook?请帮助我..

4

1 回答 1

5

使用如下:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image1" ofType:@"png"];
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"My hat image", @"message", data, @"source", nil];

[facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
于 2013-02-07T09:58:54.723 回答