我有一个应用程序,可以使用Facebook SDK将本机(MOV文件)视频发布到FacebookiOS。它一直运行正常,直到几周前才出现以下错误:
error = {
code = 352;
message = "(#352) Sorry, the video file you selected is in a format that we don't support.";
type = OAuthException;
};
完整的错误字符串是:
error Domain = com . Facebook . SDK Code = 5 "操作无法完成。(com.facebook.sdk错误5。)" UserInfo = 0x1ea 42880 { com . Facebook . SDK:HTTPStatusCode = 400,com . Facebook . SDK:ParsedJSONResponseKey = { body = { error = { code = 352;message = "(#352)抱歉,我们不支持您选择的视频文件的格式。";type = OAuthException};};代码= 400;headers =({ name = " Access-Control-Allow-Origin ";value = " *},{ name = " Cache-Control ";value = " no-store ";},{ name = Connection值=关闭;},{ name = " Content-Type ";value = " text/JavaScript;charset = UTF-8 ";},{ name = Expiresvalue = " 2000年1月1日星期六00:00:00 GMT ";},{ name = Pragmavalue = "无缓存";},{ name = " WWW-Authenticate ";value = " OAuth \ " Facebook Platform \ " \ " invalid _ request \ " \ "(# 352)抱歉,我们不支持您选择的视频文件的格式。\"";},{ name = " x-f b-load mon ";value = "0,30,70 ";} );},com . Facebook . SDK:ErrorSessionKey =,expiration date:4001-01-01 00:00:00 0000,refresh date:2013-10-15 17:19:33 0000,attempted refresh date:2013-10-24 14:56:54 0000,权限:(" share_item ",email," user_photos "," user_videos "," publish_checkins "," manage_pages "," read
我用来发布的代码与此类似:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
videoData,@"video.mov",
@"video/quicktime", @"contentType",
title, @"title",
status, @"description",
nil];
FBRequest* request = [FBRequest requestWithGraphPath:[NSString stringWithFormat:@"%@/videos",@"me"]
parameters:params
HTTPMethod:@"POST"];
[request setSession:session];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0ul);
dispatch_async(queue, ^{
dispatch_async(dispatch_get_main_queue(), ^(void) {
[request startWithCompletionHandler:^(FBRequestConnection* conn, id data, NSError* error){
SSLog(@"DONE!");
[self processResponseWithData:data requestIdentifier:requestIdentifier andError:error];
}];
});
});
我已更新到最新的SDK版本(3.9),但错误仍然存在。任何机构正在经历此错误?
我是用iOS6和iOS7测试的,所以问题与操作系统版本无关。同样的视频使用iOS-脸书内置功能上传okey。
非常感谢!
就在FB请求
之前 添加一行以打开FB请求连接
为我工作。
[FBRequestConnection startWithGraphPath:@"me/videos"
completionHandler:^(FBRequestConnection *connection,
id result, NSError *error)
{
FBRequest *uploadRequest =
[FBRequest requestWithGraphPath:@"me/videos"
parameters:params HTTPMethod:@"POST"];
}];
上面的答案有效。但请确保您创建了Facebook会话,使用openActiveSessionWithPublishPerams而不是openActiveSessionWithReadPerams。
我花了一天时间在这上面,因为如果你用错了一个,你会得到著名的“(#352)对不起,你选择的视频文件的格式我们不支持。”
无论如何,您真正需要的唯一权限是publish_actions
我不使用key contentType
int参数。它与脸书SDK 3.10(最新版本)配合良好
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSString* videoName = [filePath lastPathComponent];
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:caption forKey:@"description"];
[params setObject:videoData forKey:videoName];
FBRequestConnection *requestConnection = [FBRequestConnection startWithGraphPath:@"me/videos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
}];