简体   繁体   中英

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

I want to post some photos Or Link on user Facebook wall without using FBSDKShareDialog . I am already post With using the FBSDKSharePhoto And FBSDKShareDialog default dialog from facebook. for that I do the below code

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];

But, this code open the Default FB dialog. So, how can I directly post the link and photos ON user's wall.

You can use SLComposeViewController of default iOS Social Framework

#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];

    }
}

Documentation for Facebook Sharing. : https://developers.facebook.com/docs/sharing/ios

Through Graph 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM