简体   繁体   中英

Sharing Video to facebook via FB SDK for iOS

I have a video created in my app. I want to shared this video to user's Facebook wall via facebook native SDK. I am able to get the video sharing working, but there is no preview/share dialog shown to the user before sharing. The video is directly posted to user's wall. Here is my code to get open an active session

[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceOnlyMe allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error){}

Once I get the session active, I call the below method to share the video

- (void)sendVideoFeedRequestWithParams:(NSMutableDictionary *)params
{
// create the connection object
FBRequestConnection *newConnection = [[FBRequestConnection alloc] init];

// create a handler block to handle the results of the request
FBRequestHandler handler =
^(FBRequestConnection *connection, id result, NSError *error) {
    // output the results of the request
    [self requestCompleted:connection result:result error:error];
};

// create the request object, using the /me as the graph path
FBRequest *request = [[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:@"me/videos" parameters:params HTTPMethod:@"POST"];

// add the request to the connection object, if more than one request is added
// the connection object will compose the requests as a batch request; whether or
// not the request is a batch or a singleton, the handler behavior is the same,
// allowing the application to be dynamic in regards to whether a single or multiple
// requests are occuring
[newConnection addRequest:request completionHandler:handler];

// if there's an outstanding connection, just cancel
[self.requestConnection cancel];

// keep track of our connection, and start it
self.requestConnection = newConnection;
[newConnection start];

}

The params I am sending to this method are:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               videoData, @"video.mov",
                               @"video/quicktime", @"contentType",
                               @"Video Test Title", @"title",
                               @"Video Test Description", @"description",
                               nil];

This works well as far as posting the video is concerned. But, I want a share/preview dialog to be shown. Anybody got any hints on how to get it done?

You need to create something yourself or search for an existing solution on github (or similar). Something like a custom alert view where you can allow the user to enter text, have a thumbnail of the video which plays when tapped and a couple of buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM