0

可能重复:
如何将照片发布到 facebook iphone fbconnect

我正在使用 FB SDK 并在我的视图中从我的应用程序上传 FB 帖子上的图片时出现错误,我确实加载了我拥有的 UIImageView,它有一个我需要在 FB 上发布的图像,视图的代码确实加载了

ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 65)];
ImageView.center = CGPointMake(42, 43);
[View addSubview:ImageView];

在我的 FB post 方法中,我做到了

   UIImage *image = [[UIImage alloc]init];
   image = ImageView.image;

   NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:3];


   [params setObject:@"LINK_HERE" forKey:@"link"];


// due to this line below, i am getting an error :
// "[UIImage length]: unrecognized selector sent to instance 0x170fa0e0" 
// and if use http link instead of image(UIImage) it works, but i want to use my image
   [params setObject:image forKey:@"picture"];    

   [params setObject:@"NAME_HERE" forKey:@"name"];
   [params setObject:@"DEC_HERE" forKey:@"description"];

// Invoke the dialog
       [self.facebook dialog:@"feed" andParams:params andDelegate:self];

我应该如何在这段代码中使用我的 UIImage ......任何想法?

4

3 回答 3

0

你可以像这样简单地发布你的图片

UIImage *imgSource = {insert your image here};
NSString *strMessage = @"Images Description";
NSMutableDictionary* photosParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                     imgSource,@"source",
                                     strMessage,@"message",
                                     nil];

[self.facebook requestWithGraphPath:@"me/photos"
                                 andParams:photosParams
                             andHttpMethod:@"POST"
                               andDelegate:self];   
于 2013-01-24T12:26:30.313 回答
0

您只能在 Facebook 对话框方法中上传基于 URL 的图像。在应用程序或应用程序包中生成的图像无法上传。

要上传这些图像,您必须使用图形 API

示例代码

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
    image, @"source", 
    @"caption desc", @"message",             
    nil];
  [facebook requestWithGraphPath:[NSString stringWithFormat:@"/me/photos?access_token=%@", self.facebook.accessToken]
  andParams:params andHttpMethod:@"POST" andDelegate:self];
于 2013-01-24T12:20:06.563 回答