Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The operation couldn’t be completed. (com.facebook.sdk error 5.) FACEBOOK VIDEO UPLOAD

Tags:

ios

facebook

I wrote following code for uploading video to facebook from iOS device.

-(void)uploadVideo {

    NSLog(@"UPload Videio ");


    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"mov"];

    NSLog(@"Path is %@", filePath);

    NSData *videoData = [NSData dataWithContentsOfFile:filePath];

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   videoData, @"video.mov",
                                   @"video/quicktime", @"contentType",
                                   @"Video Test Title", @"title",
                                   @"Video Test Description", @"description",
                                   nil];
    //  [facebook requestWithGraphPath:@"me/videos"
    //                         andParams:params
    //                     andHttpMethod:@"POST"
    //                       andDelegate:self];

    if (FBSession.activeSession.isOpen) {


        [FBRequestConnection startWithGraphPath:@"me/videos"
                                     parameters:params
                                     HTTPMethod:@"POST"
                              completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

                                  if(!error) {
                                      NSLog(@"OK: %@", result);
                                  } else
                                      NSLog(@"Error: %@", error.localizedDescription);

                              }];

    } else {

        // We don't have an active session in this app, so lets open a new
        // facebook session with the appropriate permissions!

        // Firstly, construct a permission array.
        // you can find more "permissions strings" at http://developers.facebook.com/docs/authentication/permissions/
        // In this example, we will just request a publish_stream which is required to publish status or photos.

        NSArray *permissions = [[NSArray alloc] initWithObjects:
                                @"publish_stream",
                                nil];



        //[self controlStatusUsable:NO];
        // OPEN Session!
        [FBSession openActiveSessionWithPermissions:permissions
                                       allowLoginUI:YES
                                  completionHandler:^(FBSession *session,
                                                      FBSessionState status,
                                                      NSError *error) {
                                      // if login fails for any reason, we alert
                                      if (error) {

                                          // show error to user.

                                      } else if (FB_ISSESSIONOPENWITHSTATE(status)) {

                                          // no error, so we proceed with requesting user details of current facebook session.


                                          [FBRequestConnection startWithGraphPath:@"me/videos"
                                                                       parameters:params
                                                                       HTTPMethod:@"POST"
                                                                completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                                                    //  [FBRequestConnection setVideoMode:NO];

                                                                    if(!error) {
                                                                        NSLog(@"VEEERRRRRRR: %@", result);
                                                                    } else
                                                                        NSLog(@"VVEEERRRRREEEERRR: %@", error.localizedDescription);

                                                                }];





                                          //[self promptUserWithAccountNameForUploadPhoto];
                                      }
                                      // [self controlStatusUsable:YES];
                                  }];
    }
}

This gives me error The operation couldn’t be completed. (com.facebook.sdk error 5.)

I don't know what is wrong with facebook. It uploads image, text, but in video it gives this error.

NOTE:

  1. It is not due to send again and again, as I also tested by making new account and resetting iOS Device.
  2. sample.mov also exists and works with graph api, but issue is with this SDK.

Thanks.

like image 630
Chatar Veer Suthar Avatar asked Oct 27 '13 11:10

Chatar Veer Suthar


1 Answers

Few causes for seeing com.facebook.sdk error 5:

  • Session is is not open. Validate.
  • Facebook has detected that you're spamming the system. Change video name.
  • Facebook has a defined limit using the SDK. Try a different app.
  • Wrong publish permission. Give publish_actions a spin.
  • more here... ?
like image 137
David McGraw Avatar answered Oct 26 '22 14:10

David McGraw