Iphone sdk upload video to facebook

I am trying to download a video from an iPhone application using FBConnect. In fact, I tried several methods, but, unfortunately, without any success.

At first. Using the "facebook.video.upload" REST method and the tricks described here iPhone Facebook Video upload . As a result, the server returns an empty response, and after that something else happens. The video does not display on facebook. Tried various types of facebook applications, by the way, for example, WebApp and Native.

Secondly. Using the "me / videos" GRAPH method and below code to start the download

<P →
     NSMutableDictionary *params = [NSMutableDictionary
 dictionaryWithObjectsAndKeys:movieData,
 @"source", @"File.mov", @"filename",
 nil];
[m_facebook requestWithGraphPath:@"me/videos"

and Params: params and HttpMethod: @ "POST" andDelegate: itself];

In this case, I get the following errors:

a) .

b) .

. , video@facebook.com. . , .

2 , , . -, , , , , .

!

+5
4

Graph, API - . .

, Facebook, - . , , : http://developers.facebook.com/docs/authentication

upload_video, - " ".

, Facebook . , Apple, , , . , .

+4
NSURL *urlvideo = [info objectForKey:UIImagePickerControllerMediaURL];
NSString *urlString=[urlvideo path];

NSLog(@"urlString=%@",urlString);
NSString *str = [NSString stringWithFormat:@"you url of server"];
NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setFile:urlString forKey:@"key foruploadingFile"];
[request setRequestMethod:@"POST"];
[request setDelegate:self];
[request startSynchronous];
NSLog(@"responseStatusCode %i",[request responseStatusCode]);
NSLog(@"responseStatusCode %@",[request responseString]);
+1

Facebook .

, . http://developers.facebook.com/attachment/VideoUploadTest.zip , -. AppID . 3-

facebook = [[Facebook alloc] initWithAppId: @ "..." ]; 2 plist - FacebookAppID, URL http://i.stack.imgur.com/yZAXQ.png

- (IBAction)buttonClicked:(id)sender {
     NSArray* permissions = [[NSArray alloc] initWithObjects:
                        @"publish_stream", nil];
[facebook authorize:permissions delegate:self];
[permissions release];
}

- (void)fbDidLogin {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"buf-3" ofType:@"mov"];
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];
}

!

0

. FaceBook SDK 3.14.1

: 3 .plist

FacebookAppID, FacebookDisplayName,
URL-- > 0- > URL, facebookappId fb .

-(void)shareOnFaceBook
{
    //sample_video.mov is the name of file
    NSString *filePathOfVideo = [[NSBundle mainBundle] pathForResource:@"sample_video" ofType:@"mov"];

    NSLog(@"Path  Of Video is %@", filePathOfVideo);
    NSData *videoData = [NSData dataWithContentsOfFile:filePathOfVideo];
    //you can use dataWithContentsOfURL if you have a Url of video file
    //NSData *videoData = [NSData dataWithContentsOfURL:shareURL];
    //NSLog(@"data is :%@",videoData);
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               videoData, @"video.mov",
                               @"video/quicktime", @"contentType",
                               @"Video name ", @"name",
                               @"description of Video", @"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);
                                  [self throwAlertWithTitle:@"Success" message:@"Video uploaded"];
                              }
                              else
                              {
                                  NSLog(@"ERROR: %@", error.localizedDescription);
                                  [self throwAlertWithTitle:@"Denied" message:@"Try Again"];
                              }
                          }];
    }
    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);
                                         }
                                         else if (FB_ISSESSIONOPENWITHSTATE(status))
                                         {
                                             [FBRequestConnection startWithGraphPath:@"me/videos"
                                                                          parameters:params
                                                                          HTTPMethod:@"POST"
                                                                   completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                                                       if(!error)
                                                                       {
                                                                           [self throwAlertWithTitle:@"Success" message:@"Video uploaded"];

                                                                           NSLog(@"RESULT: %@", result);
                                                                       }
                                                                       else
                                                                       {
                                                                           [self throwAlertWithTitle:@"Denied" message:@"Try Again"];

                                                                           NSLog(@"ERROR: %@", error.localizedDescription);
                                                                       }

                                                                   }];
                                         }
                                     }];
        }
}

GOT Error :

 The operation couldnt be completed. (com.facebook.sdk error 5.)

, facebook . , , , . , , , SDK Facebook.

A few reasons to watch com.facebook.sdk error 5:

  • The session is not open. Verification
  • Facebook has detected that you are a spam system. Change the name of the video.
  • Facebook has a certain limit using the SDK. Try another app.
  • Invalid permission to publish. Give a publish_actionsback.
0
source

All Articles