Question: I am wondering if it's possible to post something on a user's facebook wall using SLComposeViewController but without showing the share sheet/dialog?

Following is the code I am using:

```
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {

                NSLog(@"Cancelled");

            } else

            {
                NSLog(@"Done");
            }

            [controller dismissViewControllerAnimated:YES completion:Nil];
        };
        controller.completionHandler =myBlock;

        [controller setInitialText:eventInfoToFacebook];

        [self presentViewController:controller animated:YES completion:Nil];

    }

```

Thanks in advance.

Answer: 
Import the Social Framework:

```
#import <Social/Social.h>

```

-

```
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {

                NSLog(@"Cancelled");

            } else

            {
                NSLog(@"Done");
            }

            [controller dismissViewControllerAnimated:YES completion:Nil];
        };
        controller.completionHandler =myBlock;

        [controller setInitialText:@"Test Post from mobile.safilsunny.com"];
        [controller addURL:[NSURL URLWithString:@"http://www.mobile.safilsunny.com"]];
        [controller addImage:[UIImage imageNamed:@"fb.png"]];

        [self presentViewController:controller animated:YES completion:Nil];

    }
    else{
        NSLog(@"UnAvailable");
    }

}

```

/

```
//Deprecated in iOS6

    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

    [accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {

        ACAccount *account = [[ACAccount alloc] initWithAccountType:accountType];
        NSLog(@"%@, %@", account.username, account.description);
    }];

```
Add below Code in your ViewController and import below framework.

```
import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit

@IBAction func btnPostClick(_ sender: Any)
 {
        if (FBSDKAccessToken.current() != nil)
        {
            if FBSDKAccessToken.current().hasGranted("publish_actions"){
                postOnFB()
            }
            else
            {
                let loginManager = FBSDKLoginManager()
                loginManager.logIn(withPublishPermissions: ["publish_actions"], from: self, handler: { (result, error) in
                    if error == nil{
                       self.postOnFB()
                    }
                    else{
                        print(error?.localizedDescription ?? "")
                    }
                })
            }
        }
        else
        {
            let loginManager  = FBSDKLoginManager()
            loginManager.logIn(withPublishPermissions: ["publish_actions"], from: self, handler: { (result, error) in
                if error == nil{
                    self.postOnFB()
                }
            })
        }
    }

 func postOnFB() 
   {
        FBSDKGraphRequest(graphPath: "me/feed", parameters: ["message": "YOUR MESSAGE"], httpMethod: "POST").start { (connection, result, error) in
            if error == nil{
                print("post id \(result ?? "")")
           }
            else{
                print("error is \(error?.localizedDescription ?? "")")
            }
        }
    }

```