• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 从 iOS 将视频上传到 facebook - 无法向用户请求登录权限,错误代码 6

[复制链接]
菜鸟教程小白 发表于 2022-12-12 14:20:12 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在使用 iOS 6 中的社交框架将 facebook 视频上传集成到我的应用程序中。但是,当我运行该程序时没有任何反应,而是收到以下错误:

The operation couldn’t be completed. (com.apple.accounts error 6.)

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

下面是我的代码,前半部分是我从 tutorial 实现的. granted 设置为 false,导致第一个错误。

- (void)uploadToFb {

    ACAccountStore *accountStore = [[ACAccountStore alloc] init];

    ACAccountType *facebookAccountType = [accountStore
                                          accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

    // Specify App ID and permissions
    NSDictionary *options = @{
                               ACFacebookAppIdKey: @"2************",
                               ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],
                               ACFacebookAudienceKey: ACFacebookAudienceFriends
    };

    [accountStore requestAccessToAccountsWithType:facebookAccountType
                                          optionsptions completion:^(BOOL granted, NSError *e) {

          if (granted) 
          {
              NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
              facebookAccount = [accounts lastObject];
          }
          else
          { 
           NSLog(@"Error %@", e.localizedDescription);                                              }

          }
    }];

    NSURL *videourl = [NSURL URLWithString"https://graph.facebook.com/me/videos"];

    NSString *filePath = [outputURL path];
    NSURL *pathURL = outputURL;
    NSData *videoData = [NSData dataWithContentsOfFile:filePath];

    NSDictionary *params = @{
    @"title": @"Face Puppets Video",
    @"description": @"A funny video I made with the #FacePuppets iOS app."
    };

    SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                                  requestMethod:SLRequestMethodPOST
                                                            URL:videourl
                                                     parameters:params];
    [uploadRequest addMultipartData:videoData
                           withName"source"
                               type"video/quicktime"
                           filename:[pathURL absoluteString]];

    uploadRequest.account = facebookAccount;

    [uploadRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
        if(error){
            NSLog(@"Error %@", error.localizedDescription);
        }else
            NSLog(@"%@", responseString);
    }];
}



Best Answer-推荐答案


嗨,这是一个非常好的分享示例iOS (Wiki) (Sample Project for iOS, ~3 MB)使用它,您可以将视频分享到 Facebook、YouTube、Flicker、Vimeo 查看上面的链接并测试此示例。

你需要在ESSViewController.m类中设置你的AppId 在这个方法中:

- (IBAction)facebookid)sender
{
    self.fb = [[[ESSFacebook alloc] initWithDelegate:self
                                               appID"youAppID"
                                           appSecret"secret"] autorelease];
    NSURL *url = [[NSBundle mainBundle] URLForResource"IMG_1203" withExtension"MOV"];
    [self.fb uploadVideoAtURL:url];
}

这可能是 Facebook 的旧版本,但用于获取有关如何处理来自 ourApp 的共享视频的想法。

关于ios - 从 iOS 将视频上传到 facebook - 无法向用户请求登录权限,错误代码 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18653228/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap