我想使用Facebook SDK中的FBDialog
,但似乎只需要一个用于发布图片的网址。有没有办法在发布之前使用UIImage
将FBDialog
上传到Facebook,而无需将图片上传到其他服务器?
我目前正在使用此功能在Facebook上发布UIImage
:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"A caption", @"caption",
nil];
[_facebook requestWithMethodName:@"photos.upload" andParams:params andHttpMethod:@"POST" andDelegate:nil];
效果很好,但我需要FBDialog
。有没有办法用FBDialog
做同样的事情?
感谢任何帮助。
答案 0 :(得分:2)
不,要发布UIImage
,您无法直接附加它。这有两种方法:
有关更深入的教程,请查看此链接:
Official Facebook iOS Tutorial
This is a similar question with a great answer that provides step by step tutorial
答案 1 :(得分:2)
从Facebook iOS SDK v3.13 +开始,您可以presentShareDialogWithPhotoParams
直接从设备上传图片。请参阅以下示例代码:
FBShareDialogPhotoParams *photoParams = [FBShareDialogPhotoParams new];
UIImage *screenshot = //image you want to share.
photoParams.photos = @[screenshot];
[FBDialogs presentShareDialogWithPhotoParams:photoParams
clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
}];
答案 2 :(得分:1)
- (void) feedDialogButtonClicked {
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Testing Feed Dialog", @"name",
@"Feed Dialogs are Awesome.", @"caption",
@"Check out how to use Facebook Dialogs.", @"description",
@"http://www.example.com/", @"link",
@"http://fbrell.com/f8.jpg", @"picture",
nil];
[facebook dialog:@"feed"
andParams:params
andDelegate:self];
}
来自官方Facebook iOS教程,由Rohan发布