0
votes

Following much research as I could do, I have tried to post facebook video using the following:

   NSDictionary *params = [ NSDictionary dictionaryWithObjectsAndKeys:
                                filmData, @"video.mov",     // @"source",
                                @"video/m4v", @"contentType",
                                @"Figure It!", @"title",
                                @"Figure It! Film", @"description",
                                nil
                                ];


    /* make the API call */
    NSString* graphPath = [ NSString stringWithFormat:@"%@/me/videos", facebook_video_base_url ];

    FBRequest *request = [ FBRequest requestWithGraphPath:graphPath 
                                               parameters:params
                                               HTTPMethod:@"POST" ];

    [ request startWithCompletionHandler:^(
                                           FBRequestConnection *connection,
                                           id result,
                                           NSError *error
                                           )

These are my observations:

  1. If I post to https://graph-video.facebook.com/me/videos, it always returns me the generic answer which has the id for the root object /me/videos. The id for this is always 10150481253673034.
  2. If post to me/videos then I get the error "(#352) Sorry, the video file you selected is in a format that we don't support."
  3. I have used description instead of message, and I also used title.
  4. I have used @"video.mov" instead of @"source",
  5. I have used @"contentType", though some answers have it as @"content-Type". I tried both options.
  6. Then some answers have @"ContentType" as @"multipart/formdata" and others have it as @"video/quicktime". I have tried both with no difference in result.

I read the documentation in the Facebook header file, and it says that if you supply NSData as parameter it is sent as HTTP attachment, so it will not be sent as multipart data. And if I do the assembly of the HTTP body myself there is no API to make a FBRequest with an pre assembled HTTP body.

Nothing I do gives me back an id for a newly uploaded video. If anyone can help, that would be great. Thanks,

1

1 Answers

0
votes

I finally figured out the problem.

The problem was that my session was open on ReadPermissions and not on PublishPermissions. So I reopened my FBSession with @"publish-actions" using openActiveSessionWithPublishPermissions and the problem got resolved.

So we can simply post with me/videos, and facebook seems to handle it fine.

So I did not need to post to graph-video.facebook.com and neither did I need to worry about multipart bodies. This might change later in the future because the API asks for it so at that time I will have to figure it out.

Now I am able to post fine.