【发布时间】:2013-10-27 11:29:04
【问题描述】:
我编写了以下代码,用于从 iOS 设备将视频上传到 Facebook。
-(void)uploadVideo {
NSLog(@"UPload Videio ");
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"mov"];
NSLog(@"Path is %@", filePath);
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData, @"video.mov",
@"video/quicktime", @"contentType",
@"Video Test Title", @"title",
@"Video Test Description", @"description",
nil];
// [facebook requestWithGraphPath:@"me/videos"
// andParams:params
// andHttpMethod:@"POST"
// andDelegate:self];
if (FBSession.activeSession.isOpen) {
[FBRequestConnection startWithGraphPath:@"me/videos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
NSLog(@"OK: %@", result);
} else
NSLog(@"Error: %@", error.localizedDescription);
}];
} else {
// We don't have an active session in this app, so lets open a new
// facebook session with the appropriate permissions!
// Firstly, construct a permission array.
// you can find more "permissions strings" at http://developers.facebook.com/docs/authentication/permissions/
// In this example, we will just request a publish_stream which is required to publish status or photos.
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"publish_stream",
nil];
//[self controlStatusUsable:NO];
// OPEN Session!
[FBSession openActiveSessionWithPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// if login fails for any reason, we alert
if (error) {
// show error to user.
} else if (FB_ISSESSIONOPENWITHSTATE(status)) {
// no error, so we proceed with requesting user details of current facebook session.
[FBRequestConnection startWithGraphPath:@"me/videos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
// [FBRequestConnection setVideoMode:NO];
if(!error) {
NSLog(@"VEEERRRRRRR: %@", result);
} else
NSLog(@"VVEEERRRRREEEERRR: %@", error.localizedDescription);
}];
//[self promptUserWithAccountNameForUploadPhoto];
}
// [self controlStatusUsable:YES];
}];
}
}
这给了我错误 操作无法完成。 (com.facebook.sdk 错误 5。)
我不知道 Facebook 出了什么问题。它上传图像、文本,但在视频中却出现此错误。
注意:
- 不是一次次发送,因为我也通过创建新帐户和重置iOS设备进行了测试。
- sample.mov 也存在并可与图形 api 一起使用,但问题在于此 SDK。
谢谢。
【问题讨论】:
-
老兄找到解决办法了吗??因为我也有同样的问题
-
你试过把@"title"改成@"name"吗? developers.facebook.com/docs/reference/api/video中没有名为“title”的字段