发布包含UIImage在内的Facebook链接

时间:2012-10-26 11:21:51

标签: iphone objective-c ios facebook

我想在Facebook时间轴上发布包含图片的链接:

UIImage *img = [UIImage imageNamed:@"1.png"];
    self.postParams =
    [[NSMutableDictionary alloc] initWithObjectsAndKeys:
     @"Here we go", @"message",
     @"https://developers.facebook.com/ios", @"link",
     UIImagePNGRepresentation(img), @"picture",
     @"Facebook SDK for iOS", @"name",
     @"Build great social apps and get more installs.", @"caption",
     @"The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.", @"description",
     nil];

    [FBRequestConnection startWithGraphPath:@"me/feed" parameters:self.postParams HTTPMethod:@"POST"
                          completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                              [self showAlert:@"Link is posted" result:result error:error];
    }];

UIImage没有发布。你能救我吗?

但是,如果我使用:

@"https://developers.facebook.com/attachment/iossdk_logo.png", @"picture"

它有效。

1 个答案:

答案 0 :(得分:3)

如果您阅读the documentation,则说“picture”参数应为string类型,即:url。如果没有一些聪明的hackory,您无法同时发布移动SDK中的图像和消息:请参阅文档中的我/照片,但您的选项受到严格限制。