1

我有我正在开发的这种方法,它会将视频从我的应用程序上传到 Facebook,但是我收到请求超时错误。

视频大小:1.5mb~
视频类型:mp4

代码:

NSData *movieData = [NSData dataWithContentsOfURL:finalVideoPath];
    NSLog(@"movie size: %.2f",(float)movieData.length/1024.0f/1024.0f);

    NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:movieData,@"video.mp4",@"My Video",@"title",@"Some Description",@"description", nil];
    FBRequest *request = [FBRequest requestWithGraphPath:@"me/videos" parameters:parameters HTTPMethod:@"POST"];

    //NSDictionary *parameters = [NSDictionary dictionaryWithObject:movieData forKey:@"harlemshake.mov"];
    [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (error){
            NSLog(@"result: %@, error: %@", result, error);
            return;
        }

        NSLog(@"Video Posted!");

    }];

错误详情:

    error: Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1f0f3860 
{com.facebook.sdk:ErrorInnerErrorKey=Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x1f0d4fc0 {NSErrorFailingURLStringKey=https://graph.facebook.com/me/videos?access_token=BAACCZCfPURoQBAGiIZBPAs7BbWMaqI84u0we0bN8IzfrdG4AeMxPF1ZAXq6sX3aOzjkrs8GacICZBItYnMJkyo2ySomdieggYdtNtyfjTbSA46eJZBGmV2UcOelPTNhcFVVJ48pHLmklRHUQszAAgfg9QZCqZCUQuSE027r9dq5Snmr0aQZAr8ql0uh0B6ZBXLE7dsFJ3etjwMuWnMfT15Cz6zQpoMDuQS4fuCQUZAZAFPqQwZDZD&migration_bundle=fbsdk%3A20130120&description=Some%20Description&format=json&sdk=ios&
title=My%20Video, NSErrorFailingURLKey=https://graph.facebook.com/me/videos?access_token=BAACCZCfPURoQBAGiIZBPAs7BbWMaqI84u0we0bN8IzfrdG4AeMxPF1ZAXq6sX3aOzjkrs8GacICZBItYnMJkyo2ySomdieggYdtNtyfjTbSA46eJZBGmV2UcOelPTNhcFVVJ48pHLmklRHUQszAAgfg9QZCqZCUQuSE027r9dq5Snmr0aQZAr8ql0uh0B6ZBXLE7dsFJ3etjwMuWnMfT15Cz6zQpoMDuQS4fuCQUZAZAFPqQwZDZD&migration_bundle=fbsdk%3A20130120&description=Some%20Description&format=json&sdk=ios&title=My%20Video, NSLocalizedDescription=The request timed out.,
 NSUnderlyingError=0x1f0ea5f0 "The request timed out."}, com.facebook.sdk:HTTPStatusCode=200, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x1f03f460, state: FBSessionStateOpen, loginHandler: 0x1f040700, appID: 144027229111940, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x1f03fb00>, expirationDate: 4001-01-01 00:00:00 +0000, refreshDate: 2013-04-11 19:54:01 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(
        "user_videos",
        "publish_stream",
        email
    )>}
4

1 回答 1

0

尝试打开一个 FBRequestConnection(它允许您设置一个长超时),然后将 FBRequest 添加到连接中。这是一个代码片段:

FBRequestConnection *connection = [[[FBRequestConnection alloc] initWithTimeout:200.0] autorelease];
        FBRequest *request = [FBRequest requestWithGraphPath:@"me/videos"
                                                  parameters:parameters
                                                  HTTPMethod:@"POST"];

        [connection addRequest:request
             completionHandler:^(FBRequestConnection *connection,
                                 id result,
                                 NSError *error) {
于 2013-08-22T19:09:53.777 回答