我想上傳視頻。我救了我的視頻文件的MP4文件,如下所示:通過video-graph.facebook上傳視頻到Facebook iOS
NSString *fileName = [NSString stringWithFormat:@"chatVideo-%d.mp4",arc4random()%1000];
NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:fileName];
NSURL *videoURL = [NSURL fileURLWithPath:myPathDocs];
AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:asset2 presetName:AVAssetExportPresetHighestQuality];
exportSession.outputURL = videoURL;
exportSession.outputFileType = AVFileTypeMPEG4;
NSData *videodata =[NSData dataWithContentsOfURL:videoURL];
我所說的圖形API,用於上傳到Facebook:
[parameters setValue:videoData forKey:@"source"];
[parameters setValue:thumbData forKey:@"thumb"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/videos"
parameters:parameters
HTTPMethod:@"POST"]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if ([error.userInfo[FBSDKGraphRequestErrorGraphErrorCode] isEqual:@200]) {
NSLog(@"permission error");
}
}];
但我收到此錯誤:
Sorry, the video file you selected is in a format that we don't support.
跆拳道...我有同樣的問題,是試圖做手動形式multipart/form編碼,什麼不...最後,它只是用'video.mp4'來改變'source'。你在哪裏找到這個,如果你還記得的話?(好奇心) –
@MartínMarconcini我參考這個來源:https://github.com/lucascorrea/SCFhotos –
謝謝,Facebook文檔的目標是非常完整,但它已被不同的人/團隊明確寫入,有時是一團糟 –