使用 iOS SDK 将大型视频上传到 Facebook
Posted
技术标签:
【中文标题】使用 iOS SDK 将大型视频上传到 Facebook【英文标题】:Upload large videos to Facebook with iOS SDK 【发布时间】:2013-07-29 15:15:16 【问题描述】:如何在 ios Facebook SDK 中上传大型视频?我有一个 4 分钟的视频,总是出现未知错误。
【问题讨论】:
【参考方案1】:我必须像这样为视频参数构建我的 NSData:
videoData = [NSData dataWithContentsOfURL:url options:NSDataReadingMappedAlways error:&error];
我还必须在 FBRequestConnection.m 中更改此方法,然后事情开始起作用了:
//
// Generates a URL for a batch containing only a single request,
// and names all attachments that need to go in the body of the
// request.
//
// The URL contains all parameters that are not body attachments,
// including the session key if present.
//
// Attachments are named and referenced by name in the URL.
//
- (NSString *)urlStringForSingleRequest:(FBRequest *)request forBatch:(BOOL)forBatch
[request.parameters setValue:@"json" forKey:@"format"];
[request.parameters setValue:kSDK forKey:@"sdk"];
NSString *token = request.session.accessTokenData.accessToken;
if (token)
[request.parameters setValue:token forKey:kAccessTokenKey];
[self registerTokenToOmitFromLog:token];
NSString *baseURL;
if (request.restMethod)
if (forBatch)
baseURL = [kBatchRestMethodBaseURL stringByAppendingString:request.restMethod];
else
baseURL = [kRestBaseURL stringByAppendingString:request.restMethod];
else
if (forBatch)
baseURL = request.graphpath;
else
NSString *const kVideoGraphBaseURL = @"https://graph-video." FB_BASE_URL @"/";
if (([request.HTTPMethod isEqualToString:@"PUT"] || [request.HTTPMethod isEqualToString:@"POST"]) && [request.graphPath rangeOfString:@"videos"].location != NSNotFound)
baseURL = [kVideoGraphBaseURL stringByAppendingString:request.graphPath];
else
baseURL = [kGraphBaseURL stringByAppendingString:request.graphPath];
NSString *url = [FBRequest serializeURL:baseURL
params:request.parameters
httpMethod:request.HTTPMethod];
return url;
iOS SDK 中的视频支持似乎很差。
【讨论】:
如果我没记错的话,你不能上传超过 12 兆字节的视频(它写在 Facebook 技术文档中)以上是关于使用 iOS SDK 将大型视频上传到 Facebook的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Mac SDK 将大型(2 块)orbBasic 程序上传到 Sphero?
我们可以使用 Facebook SDK 将文档目录视频上传到 Facebook