【问题标题】:Facebook error getting image on post [duplicate]Facebook错误在帖子上获取图像[重复]
【发布时间】:2013-01-24 12:15:03
【问题描述】:

可能重复:
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 ......有什么想法吗??

【问题讨论】:

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


【解决方案1】:

您只能在 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];

【讨论】:

  • 得到错误错误:HTTP状态码:400
【解决方案2】:

你可以像这样发布你的图片

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

【讨论】:

  • 得到错误错误:HTTP状态码:400
【解决方案3】:

【讨论】:

  • 这并没有提供问题的答案。要批评或要求作者澄清,请在其帖子下方发表评论。
  • @Rikesh 为什么你不给出答案......对我来说,示例项目是处理你的问题的最佳方式......以及我已经给出了给他描述的链接......
  • @Rikesh 以及为什么要投反对票...如果您对 iOS 有任何了解...请查看链接...
猜你喜欢
  • 2012-08-12
  • 2011-08-18
  • 1970-01-01
  • 2016-09-25
  • 2014-08-10
  • 1970-01-01
  • 2012-07-28
  • 2021-04-05
  • 1970-01-01
相关资源
最近更新 更多