0

私のアプリケーションでは、FbConnect を使用して Facebook ウォールにビデオをアップロードしようとしていますが、私のコードは問題ないように見えますが、ビデオがアップロードされない理由がわかりません。画像のアップロードに使用するコードです

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"2" ofType:@"png"];
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfFile:filePath];
UIImage *img  = [[UIImage alloc] initWithData:data];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                             img, @"Picture",
                             nil];
[_facebook requestWithGraphPath:@"me/photos"
                    andParams:params
                    andHttpMethod:@"POST"
                    andDelegate:self];
[img release];

そしてビデオのために私はこのコードを試しています

 NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"mp4"];
 NSURL *url = [NSURL URLWithString:filePath];
 NSData *videoData = [NSData dataWithContentsOfURL:url];
 NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               videoData, @"video.mp4",
                               @"video/quicktime", @"contentType",
                               @"Video Test Title", @"title",
                               @"Video Test Description", @"description",
                               nil];
[_facebook requestWithGraphPath:@"me/videos"
                     andParams:params
                 andHttpMethod:@"POST"
                   andDelegate:self];

上記のコードではエラーは発生しませんが、ラベルにテキストメッセージが返されます(操作を完了できませんでした)。これは画像のアップロードの場合ではありません。修正方法を教えてください。

4

2 に答える 2

5

次の行を試してください。

 NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"mp4"];
      NSData *videoData = [NSData dataWithContentsOfFile:filePath];
     NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   videoData, @"video.mp4",
                                   @"video/quicktime", @"contentType",
                                   @"Video Test Title", @"title",
                                   @"Video Test Description", @"description",
                                   nil];
    [_facebook requestWithGraphPath:@"me/videos"
                         andParams:params
                     andHttpMethod:@"POST"
                       andDelegate:self];

これがあなたの助けになることを願っています。私にとってはうまくいきます。これらの行を追加してください。

于 2012-12-10T11:11:23.380 に答える
3
 http://stackoverflow.com/questions/10509984/how-to-upload-mp4-video-on-facebook-using-graph-api-in-objective-c

http://%5B1%5D:%20https://github.com/reallylongaddress/iPhone-Facebook-Graph-API

http://stackoverflow.com/questions/12861615/upload-video-to-facebook-using-facebook-new-sdk-on-ios-6-0
于 2012-12-10T11:15:51.467 に答える