如何在不使用本机 ios 应用程序的 FBSDKShareDialog 的情况下在 Facebook 墙上分享照片或 link

how to share a Photo Or link on facebook wall without using FBSDKShareDialog from native ios app

我想 post 一些照片或 Link 在用户 Facebook 墙上而不使用 FBSDKShareDialog 。我已经 post 使用来自 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 对话框。那么,我怎样才能直接post link 和用户墙上的照片。

您可以使用默认 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

3) http://www.raywenderlich.com/1488/facebook-tutorial-for-ios-how-to-use-facebook-new-graph-api-from-your-iphone-app