Facebook错误在帖子上获取图像

时间:2013-01-24 12:15:04

标签: iphone ios xcode facebook facebook-graph-api

  

可能重复:
  How to post photos to 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帖子中我做了这个

   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 ......任何想法?

3 个答案:

答案 0 :(得分: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];

答案 1 :(得分: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];   

答案 2 :(得分:-1)