0

如何在 iOS Facebook SDK 中上传大视频?我有一个 4 分钟的视频,总是出现未知错误。

4

1 回答 1

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 中的视频支持似乎很差。

于 2013-07-29T15:15:53.230 回答