简体   繁体   English

通过iOS版FB SDK将视频分享到Facebook

[英]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. 我想通过Facebook原生SDK将视频分享到用户的Facebook墙。 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). 您需要自己创建一些东西或在github(或类似文件)上搜索现有的解决方案。 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. 类似于自定义警报视图,您可以在其中允许用户输入文本,点击时播放视频的缩略图以及几个按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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