【问题标题】:How To upload Video on Facebook using FBConncet?如何使用 FBConncet 在 Facebook 上上传视频?
【发布时间】:2012-12-10 11:07:25
【问题描述】:

在我的应用程序中,我正在尝试使用 FbConnect 在 facebook 墙上上传视频,我的代码看起来不错,但我不知道为什么我的视频没有上传,因为如果我使用相同的代码方法上传图像,它会成功上传图像facebook.here 是我用于上传图片的代码

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];

上面的代码没有给我任何错误,但是它在标签中返回了一些文本消息(操作无法完成)。这不是在图片上传的情况下。所以有人可以指导我如何修复它。谢谢

【问题讨论】:

    标签: iphone xcode url video fbconnect


    【解决方案1】:

    试试以下几行:

     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];
    

    希望这对你有帮助。它对我来说工作正常。现在添加这些行。

    【讨论】:

    • NSData *videoData = [NSData dataWithContentsOffile:filePath];现在添加这一行,它对你有用。试试吧。
    【解决方案2】:
     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
    

    【讨论】:

    • Sahil 告诉我一件事,我可以修复现有代码,因为当我将它用于图像时,相同的代码可以工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-24
    • 2011-07-18
    • 2016-03-20
    • 2012-10-03
    • 1970-01-01
    相关资源
    最近更新 更多