我想在不使用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”对话框。那么,我怎样才能直接在用户的墙上发布链接和照片。
答案 0 :(得分:1)
您可以使用默认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)Post image on facebook wall using graph api iphone sdk
2)Photo Upload to own wall via iOS Graph API with user's location