出现错误'操作无法完成。 (com.facebook.sdk错误5。)'从iphone在Facebook上发布视频时

时间:2014-11-29 06:58:32

标签: ios objective-c iphone facebook facebook-graph-api

我收到错误(操作无法完成。(com.facebook.sdk错误5。))从ios设备发布视频时。我已经使用这些代码在Facebook上发布视频。

-(void)FBUploadVideoProcess
{
    NSString *finalFileName=[NSString stringWithFormat:@"Documents/Book_%d/%@_%d.mov",self.book.bookId,self.book.bookName,self.book.bookId];
    NSString *filePathOfVideo = [NSHomeDirectory()
                             stringByAppendingPathComponent:finalFileName];
    NSData *videoData = [NSData dataWithContentsOfFile:filePathOfVideo];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               videoData, @"animation1.mp4",
                               @"video/quicktime", @"contentType",
                               self.book.bookName, @"name",
                               @"FlipIt Movie", @"description",
                               nil];

   if (FBSession.activeSession.isOpen)
   {
       [FBRequestConnection startWithGraphPath:@"me/videos"
                                 parameters:params
                                 HTTPMethod:@"POST"
                          completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                              if(!error)
                              {
                                  NSLog(@"RESULT: %@", result);
                                  UIAlertView *alrtResult=[[UIAlertView alloc]initWithTitle:@"FlipIt" message:@"Upload Complete." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                                  [alrtResult show];

                                  [spinner stopAnimating];

                              }
                              else
                              {
                                  NSLog(@"ERROR: %@", error.localizedDescription);
                                  UIAlertView *alrtResult=[[UIAlertView alloc]initWithTitle:@"FlipIt" message:error.localizedDescription delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                                  [alrtResult show];
                                  [spinner stopAnimating];

                              }
                          }];
    }
    else
    {
        NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"publish_actions",
                            nil];
    // OPEN Session!
        [FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone  allowLoginUI:YES
                                     completionHandler:^(FBSession *session,
                                                         FBSessionState status,
                                                         NSError *error) {
                                         if (error)
                                         {
                                             NSLog(@"Login fail :%@",error);
                                             UIAlertView *alrtResult=[[UIAlertView alloc]initWithTitle:@"FlipIt" message:error.localizedDescription delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                                             [alrtResult show];
                                             [spinner stopAnimating];
                                         }
                                         else //if(FB_ISSESSIONOPENWITHSTATE(status))
                                         {
                                             NSLog(@"session...%d",FBSession.activeSession.isOpen);
                                             [FBRequestConnection startWithGraphPath:@"me/videos"
                                                                          parameters:params
                                                                          HTTPMethod:@"POST"
                                                                   completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                                                       if(!error)
                                                                       {

                                                                           NSLog(@"RESULT: %@", result);
                                                                           UIAlertView *alrtResult=[[UIAlertView alloc]initWithTitle:@"FlipIt" message:@"Upload Complete." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                                                                           [alrtResult show];

                                                                           [spinner stopAnimating];
                                                                       }
                                                                       else
                                                                       {


                                                                           NSLog(@"ERROR: %@", error.localizedDescription);
                                                                           UIAlertView *alrtResult=[[UIAlertView alloc]initWithTitle:@"FlipIt" message:error.localizedDescription delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                                                                           [alrtResult show];
                                                                           [spinner stopAnimating];
                                                                       }

                                                                   }];
                                         }
                                     }];
     }

}

我发现很多相关的问题,但我还没找到我的解决方案。请帮我。

1 个答案:

答案 0 :(得分:0)

您应该将目标格式与源视频格式(即mov)匹配。同时"名称"应改为" title"。

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                           videoData, @"animation1.mov",
                           @"video/quicktime", @"contentType",
                           self.book.bookName, @"title",
                           @"FlipIt Movie", @"description",
                           nil];