菜鸟教程小白 发表于 2022-12-12 14:20:12

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


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

<blockquote>
<p>The operation couldn’t be completed. (com.apple.accounts error 6.)</p>

<p>&#34;An active access token must be used to query information about the current user.&#34;,&#34;type&#34;:&#34;OAuthException&#34;,&#34;code&#34;:2500}}&#34;</p>
</blockquote>

<p>下面是我的代码,前半部分是我从 <a href="http://www.techotopia.com/index.php/IPhone_iOS_6_Facebook_and_Twitter_Integration_using_SLRequest" rel="noreferrer noopener nofollow">tutorial</a> 实现的. <code>granted</code> 设置为 <code>false</code>,导致第一个错误。</p>

<pre><code>- (void)uploadToFb {

    ACAccountStore *accountStore = [ init];

    ACAccountType *facebookAccountType = [accountStore
                                          accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

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

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

          if (granted)
          {
            NSArray *accounts = ;
            facebookAccount = ;
          }
          else
          {
         NSLog(@&#34;Error %@&#34;, e.localizedDescription);                                              }

          }
    }];

    NSURL *videourl = ;

    NSString *filePath = ;
    NSURL *pathURL = outputURL;
    NSData *videoData = ;

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

    SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                                requestMethod:SLRequestMethodPOST
                                                            URL:videourl
                                                   parameters:params];
    [uploadRequest addMultipartData:videoData
                           withName:@&#34;source&#34;
                               type:@&#34;video/quicktime&#34;
                           filename:];

    uploadRequest.account = facebookAccount;

    [uploadRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
      NSString *responseString = [ initWithData:responseData encoding:NSUTF8StringEncoding];
      if(error){
            NSLog(@&#34;Error %@&#34;, error.localizedDescription);
      }else
            NSLog(@&#34;%@&#34;, responseString);
    }];
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>嗨,这是一个非常好的分享示例<a href="https://github.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/wiki/How-To-for-iOS" rel="noreferrer noopener nofollow">iOS (Wiki) (Sample Project for iOS, ~3 MB)</a>使用它,您可以将视频分享到 <strong>Facebook、YouTube、Flicker、Vimeo</strong> 查看上面的链接并测试此示例。</p>

<p>你需要在<code>ESSViewController.m</code>类中设置你的<code>AppId</code> 在这个方法中:</p>

<pre><code>- (IBAction)facebook:(id)sender
{
    self.fb = [[ initWithDelegate:self
                                             appID:@&#34;youAppID&#34;
                                           appSecret:@&#34;secret&#34;] autorelease];
    NSURL *url = [ URLForResource:@&#34;IMG_1203&#34; withExtension:@&#34;MOV&#34;];
    ;
}
</code></pre>

<p>这可能是 Facebook 的旧版本,但用于获取有关如何处理来自 ourApp 的共享视频的想法。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 从 iOS 将视频上传到 facebook - 无法向用户请求登录权限,错误代码 6,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/18653228/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/18653228/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 从 iOS 将视频上传到 facebook - 无法向用户请求登录权限,错误代码 6