如何使用iphone sdk 4.0在facebook上传视频?

时间:2010-10-20 09:50:06

标签: facebook video ios4

我正在尝试在Facebook上传视频。但我的代码不起作用:

FBRequest *m_UploadRequest = [[FBRequest requestWithSession: _session delegate: self] retain];
NSURL *videoUrl=[NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"]; 
NSData* VideoFileData = [NSData dataWithContentsOfURL:videoUrl];
NSMutableDictionary* Parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"video.upload", @"method", @"Video Title", @"title", nil];
[m_UploadRequest call: @"facebook.video.upload" params:Parameters dataParam: VideoFileData];                          

1 个答案:

答案 0 :(得分:3)

您可以使用Facebook iOS SDK,并应使用Graph API上传视频:

NSURL *videoUrl=[NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
NSData* VideoFileData = [NSData dataWithContentsOfURL:videoUrl];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
    VideoFileData, @"video.mov",
    @"video/mp4", @"contentType",
    @"Video Title", @"title",
    nil];                                                      
[facebook requestWithGraphPath:@"me/videos"
    andParams:params 
    andHttpMethod:@"POST"
    andDelegate:self];

您可能需要等待一段时间才能将视频上传到您的个人资料中,但您最终应该会看到该视频。