1
votes

I’ve implemented the graph API POST /me/photos in my iOS app and its working fine. Same way I implemented the /me/videos with host graph-video.facebook.com suggested in Facebook documents and this link : [cURL - is there a way for upload a video to facebook without form? I get success response for this too like below but the video is not showing up on my Facebook account.

{
id = 10150481253673034;
url = "https://graph-video.facebook.com/me/videos";
}

Here is the code I have written :

NSString *str=[[NSBundle mainBundle] pathForResource:@"samplevideo" ofType:@"mov"];
NSData *imageFBData = [NSData dataWithContentsOfFile:str];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                                     imageFBData, @"source",
                                     @"multipart/form-data", @"Content-Type",
                                     message, @"message",
                                     nil];
[FBRequestConnection startWithGraphPath:@"https://graph-video.facebook.com/me/videos"
                                             parameters:params
                                             HTTPMethod:@"POST"
                                      completionHandler:^(
                                                          FBRequestConnection       *connection,
                                                          id result,
                                                          NSError *error
                                                          ) {
                                          // handle the result
                                          NSLog(@"result : %@",result);
                                          if(error)
                                              NSLog(@"error : %@",error);
                                      }];

if I use the URL as "/me/videos" like I use /me/photos instead of https://graph-video.facebook.com/me/videos, I get the below error:

{
body =     {
    error =         {
        code = 352;
        message = "(#352) Sorry, the video file you selected is in a format that we don't support.";
        type = OAuthException;
    };
};
code = 400;
}

I tried with both .mp4 and .mov which are in supported videos. I'm sure there is no issue with video because the same video I upload to amazon S3 before posting to FB and I can play the uploaded video. Here is one sample: https://tagg-social-staging.s3.amazonaws.com/uploads/posts/videos/36/post-video.mp4 Note: I'm not posting the video using the above URL, but as multipart /form-data

1

1 Answers

0
votes

I have fixed the posting video issue using the sample code provided here: https://developers.facebook.com/blog/post/2011/08/04/how-to--use-the-graph-api-to-upload-a-video--ios/ I don’t know how long it will work as it’s a deprecated code but I used the method ([FBRequestConnection startWithGraphPath:@"/me/videos") of latest v2.2 by changing API parameters : “source” to “video.mov” for video “message” to “description” for caption

Now I have one more issue: I need to tag friends from my app. I use /{photo-id}/tags for tagging a photo which is working fine and I tried the same API to tag a video as I’m not able to get any other API from FB docs. I get the below error for while tagging friends for a video:

{
body =     {
    error =         {
        code = 100;
        message = "(#100) The parameter tag_uid is required";
        type = OAuthException;
    };
};
code = 400;
}

Is there any API to tag a video from mobile app?