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

1.3k views Asked by At

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.

1

There are 1 answers

5
Ashish Kakkad On BEST ANSWER

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