0

我是objective-c的新手,我真的需要你的帮助。我已经尝试解决这个问题好几个小时了。而且我仍然找不到解决方案。这是我的代码:

-(void)post
{

        [self connectWithFacebook];
        NSLog(@"session: %hhd", FBSession.activeSession.isOpen);

        NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Here's to the Crazy Ones" ofType:@"mp4"];
        NSURL *pathURL = [[NSURL alloc]initFileURLWithPath:filePath isDirectory:NO];
        NSData *videoData = [NSData dataWithContentsOfFile:filePath];

        NSDictionary *videoObject = @{
                                      @"title": @"FB SDK 3.1",
                                      @"description": @"hello there !",
                                      [pathURL absoluteString]: videoData
                                      };
        FBRequest *uploadRequest = [FBRequest requestWithGraphPath:@"me/videos"
                                                        parameters:videoObject
                                                        HTTPMethod:@"POST"];

        NSLog(@"here i am");
        [uploadRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        NSLog(@"after upload request");
            if (!error)
                NSLog(@"Done: %@", result);
            else
                NSLog(@"Error: %@", error.localizedDescription);
        }];

}

- (void) connectWithFacebook {
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    [appDelegate openSessionWithAllowLoginUI:YES];
}

这是来自 AppDelegate

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI
{
    NSArray *permissions = @[@"publish_stream"];

    return [FBSession openActiveSessionWithReadPermissions:permissions
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                             if (error) {
                                                 NSLog (@"Handle error %@", error.localizedDescription);
                                             } else {
                                                 NSLog(@"No error");
                                             }
                                         }];
}

这是来自控制台:

2014-05-08 15:02:49.385 camera[3748:60b] 错误:操作无法完成。(com.facebook.sdk 错误 5。)

对你的帮助表示感谢。谢谢你。我真的不知道下一步该怎么做。

4

1 回答 1

0

com.facebook.sdk 错误 5 的一个可能错误是

“此状态更新与您上次发布的状态更新相同。尝试发布不同的内容,或删除您之前的更新。”

于 2014-11-12T16:05:18.457 回答