![](/img/trans.png)
[英]FBSDKShareDialog doesn't share Photo without Facebook App installed, IOS
[英]how to share a Photo Or link on facebook wall without using FBSDKShareDialog from native ios app
我想在不使用FBSDKShareDialog的情况下在用户Facebook墙上发布一些照片或链接。 我已经使用来自Facebook的FBSDKSharePhoto和FBSDKShareDialog默认对话框发布了。 为此,我执行以下代码
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.imgView.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:(id)self];
但是,此代码将打开“默认FB”对话框。 因此,如何直接在用户墙上发布链接和照片。
您可以使用默认iOS社交框架的SLComposeViewController
#import <Social/Social.h>
- (IBAction)postToFacebook:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:@"Post from my iPhone app"];
[controller addURL:[NSURL URLWithString:@"http://www.yourlink.com"]];
[controller addImage:[UIImage imageNamed:@"facebook-image.jpg"]];
[controller setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(@"Post Canceled");
break;
case SLComposeViewControllerResultDone:
NSLog(@"Post Sucessful");
break;
default:
break;
}
}];
[self presentViewController:controller animated:YES completion:Nil];
}
}
Facebook共享文档。 : https : //developers.facebook.com/docs/sharing/ios
通过图谱API:
1) 使用图形API iPhone iPhone SDK在Facebook墙上发布图像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.