【发布时间】:2013-01-07 17:00:11
【问题描述】:
我正在使用最新的 Facebook 框架 3.1 创建 iOS 应用
我已经看到很多关于将图像和文本发布到 facebook 用户墙上的内容。我正在使用以下代码。
NSDictionary* dict = @{
@"link" : @"https://developers.facebook.com/ios",
@"picture" : [UIImage imageNamed:@"Default"],
@"message":@"Your temp message here",
@"name" : @"MyApp",
@"caption" : @"TestPost",
@"description" : @"Integrating Facebook in ios"
};
[FBRequestConnection startWithGraphPath:@"me/feed" parameters:dict HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSString *alertText;
if (error)
{
NSLog(@"%@",[NSString stringWithFormat: @"error: domain = %@, code = %d", error.domain, error.code]);
alertText = @"Failed to post to Facebook, try again";
} else
{
alertText = @"Posted successfully to Facebook";
}
[[[UIAlertView alloc] initWithTitle:@"Facebook Result" message:alertText delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles:nil] show];
}];
如果我将图片作为“URL”提供,则可以正常发布。否则它的抛出错误。我想发布应用程序包中的图像。有人能告诉我我在哪里编码错误吗?
【问题讨论】:
-
看看这个教程 - 它适用于 Facebook SDK 3.0,但会得到你正在寻找的东西 - xcodenoobies.blogspot.com/2012/09/…
-
@Igy:使用您建议的 URL,我只能发布照片。我也想发布照片、消息、姓名和网址。
-
所以你想发布一个提要帖子,而不是一个照片帖子?除了尝试上传不支持的照片字节之外,您有正确的代码 - 再次查看文档,
picture参数应该是一个 URL -
@Igy 但我在应用程序中有图像。当我使用@“me/photos”时,它只是发布图像和消息,而不是其他参数。
标签: ios facebook facebook-graph-api