如何在iOS上分享/发布Facebook视频

时间:2014-07-05 06:21:50

标签: ios iphone objective-c facebook

我想通过我的应用程序分享/发布视频文件到facebook 如何分享?

试过这个,但没有工作。

NSURL *videourl = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"me" ofType:@"mov"];
NSURL *pathURL = [[NSURL alloc]initFileURLWithPath:filePath isDirectory:NO];
NSData *videoData = [NSData dataWithContentsOfFile:filePath];

NSDictionary *params = @{
                        @"title": @"Me being silly",
                        @"description": @"Me testing the video upload to Facebook with the new system."
                        };

SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                              requestMethod:SLRequestMethodPOST
                                                        URL:videourl
                                                 parameters:params];
[uploadRequest addMultipartData:videoData
                       withName:@"source"
                           type:@"video/quicktime"
                       filename:[pathURL absoluteString]];

uploadRequest.account = self.facebookAccount;

[uploadRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    if(error){
        NSLog(@"Error %@", error.localizedDescription);
    }else
        NSLog(@"%@", responseString);
}];

0 个答案:

没有答案