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

时间:2013-08-06 06:41:26

标签: ios facebook facebook-graph-api ios6

我在自己的应用中创建了一个视频。 我想通过facebook native SDK将这个视频分享给用户的Facebook墙。 我能够让视频共享工作,但在共享之前没有向用户显示预览/共享对话框。视频直接发布到用户的墙上。 这是我打开活动会话的代码

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

我启动会话后,我会调用以下方法来分享视频

- (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];

}

我发送给这种方法的参数是:

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

就发布视频而言,这很有效。但是,我希望显示共享/预览对话框。 有人知道如何完成它吗?

1 个答案:

答案 0 :(得分:1)

您需要自己创建或在github(或类似)上搜索现有解决方案。像自定义警报视图,您可以允许用户输入文本,具有在点击时播放的视频缩略图和几个按钮。