2

I have used SLComposeViewController to share image and url's as follows:

  SLComposeViewController *fbComposer =
  [SLComposeViewController
   composeViewControllerForServiceType:SLServiceTypeFacebook];

  if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
  {
   SLComposeViewControllerCompletionHandler __block completionHandler=
   ^(SLComposeViewControllerResult result){

    [fbComposer dismissViewControllerAnimated:YES completion:nil];

    switch(result){
     case SLComposeViewControllerResultCancelled:
     default:
     {
      NSLog(@"Cancelled.....");
     }
      break;
     case SLComposeViewControllerResultDone:
     {
      NSLog(@"Posted....");
      UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Sent"
                                                       message:nil
                                                      delegate:nil
                                             cancelButtonTitle:@"Dismiss"
                                             otherButtonTitles: nil];
      [alert show];
     }
      break;
    }};
    NSString *message=@"posting to FB test";
   [fbComposer setInitialText:message];
   [fbComposer addImage:[UIImage imageNamed:@"2.jpg"]];
   [fbComposer addURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=GoZ2Be2zLq8"]];
   [fbComposer setCompletionHandler:completionHandler];
   [self presentViewController:fbComposer animated:YES completion:nil];
  }

Can we also able to share video file using SLComposeViewController. Thanks in advance.

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Prince Kumar Sharma
  • 12,591
  • 4
  • 59
  • 90

2 Answers2

4

No, we can't share video file using SLComposeViewController. For sending video file we have to

use Fb Graph API. Refer this link & use it you can easily be able to send video file to fb:

http://developers.facebook.com/blog/post/2011/08/04/how-to--use-the-graph-api-to-upload-a-video--ios/

Vishal
  • 8,246
  • 6
  • 37
  • 52
0

If you want to share a video url to the Facebook, you can use the following code.

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:string];  
[controller addImage:image];
[controller addURL:[NSURL URLWithString:URLString]];
[self.controller presentViewController:controller animated:YES completion:Nil];
[controller setCompletionHandler:^(SLComposeViewControllerResult result){
            switch (result) {
                case SLComposeViewControllerResultCancelled:
                    // Cancelled
                    break;

                case SLComposeViewControllerResultDone:
                   // Success
                    break;

                default:
                    break;
            }
        }];
Vishnu Kumar. S
  • 1,797
  • 1
  • 15
  • 35
  • This won't work, Facebook does not allow you to share videos using just SLComposeViewController. As Vishal said above, you'll need to use the tutorial [here].(http://developers.facebook.com/blog/post/2011/08/04/how-to--use-the-graph-api-to-upload-a-video--ios/) – Olivia Stork Aug 05 '15 at 20:29