【问题标题】:Objective-C Facebook video sharing for the app应用程序的 Objective-C Facebook 视频共享
【发布时间】:2014-05-07 09:38:04
【问题描述】:

我对 Objective-c 非常陌生。基本上,我现在看到的都是黑色的。我被指派为我们正在制作的应用程序的 facebook 共享部分编写代码,相信我,我已经尝试了几乎所有的教程(没有一个有效,我已经尝试过)并在堆栈中解决了这里的问题,我仍然无法上传。所以请有人帮忙吗?

如何通过应用程序将视频上​​传到 Facebook?如果有,请提供示例代码。

这是我现在正在尝试的代码:

-(void)post
{
    NSURL *videourl = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];

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

    NSLog(@"PATH: %@", filePath);

    NSDictionary *params = @{
                             @"title": @"uploading",
                             @"description": @"testing..."
                             };

    NSLog(@"uploading...");

    SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                                  requestMethod:SLRequestMethodPOST
                                                            URL:videourl
                                                     parameters:params];
    [uploadRequest addMultipartData:videoData
                           withName:@"source"
                               type:@"video/quicktime"
                           filename:[pathURL absoluteString]];
    NSLog(@"Here it goes...");
    uploadRequest.account = self.facebookAccount;
    NSLog(@"Past uploadrequest...");
    [FBSession setActiveSession:FBSession.activeSession];
    [uploadRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
       // [FBSession setActiveSession:FBSession.activeSession];
        if (!FBSession.activeSession.isOpen) {
         //   [FBSession openActiveSessionWithAllowLoginUI: YES];
            [FBSession setActiveSession:FBSession.activeSession];
        }

        NSLog(@"response string: %@", responseString);
        NSLog(@"Here I am...");
        if(error){
            NSLog(@"Error %@", error.localizedDescription);
        }else
            NSLog(@"%@", responseString);
    }];
}

这样我得到一个错误:

{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}

【问题讨论】:

  • 我更新了帖子。谢谢。

标签: ios objective-c facebook ios7


【解决方案1】:

这里我提供了一个链接,它将指导您将视频上传到 FB Tutorial

【讨论】:

  • 这是最新版的 FacebookSDK 吗?
  • 如果我要使用该教程,是否可以同时使用两个版本的 SDK?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-23
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
  • 2015-09-26
相关资源
最近更新 更多