Jona Jona -4 years ago 145
Objective-C Question

The Facebook SDK seems to be missing content title and description?

I have used the Facebook API to publish videos on Facebook and I'm now working on iOS to do the same. The APIs look very similar however they are missing the contentTitle and description. How do I set that? My API usage below works perfect just missing those two fields. Anyone know how to include that?

NSURL *videoURL = [NSURL fileURLWithPath:videoPath];
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];

video.videoURL = videoURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;

// Upload video
[FBSDKShareAPI shareWithContent:content delegate:self];

Answer Source

try this code because in this method you can share only video not text and description

 if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"contact_email"]) {

    NSData *videoData = [NSData dataWithContentsOfURL:appDelegateObj.finalVideoUrl];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:3L];

    [params setObject:videoData forKey:@"videofilename.MOV"];
    [params setObject:@"Your post title" forKey:@"title"];
    [params setObject:@"Your post description" forKey:@"description"];

    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/videos" parameters:params HTTPMethod:@"POST"]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error) {
             //video posted
             NSLog(@"successfull %@:",result);
             strFbSocialPostId = [result valueForKey:@"id"];//post ID
         }
     }];
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download