2

我使用 SLComposeViewController 来共享图像和 url,如下所示:

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

我们还可以使用 SLComposeViewController 共享视频文件吗?提前致谢。

4

2 回答 2

4

不,我们不能使用 SLComposeViewController 共享视频文件。为了发送视频文件,我们必须

使用 Fb 图形 API。请参考此链接并使用它,您可以轻松地将视频文件发送到 fb:

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

于 2012-12-28T02:44:29.963 回答
0

如果您想将视频 url 分享到 Facebook,可以使用以下代码。

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;
            }
        }];
于 2015-04-09T11:11:10.767 回答