菜鸟教程小白 发表于 2022-12-13 06:22:25

ios - FB Api - 无法通过 IOS 应用将照片发布到页面的相册


                                            <p><p>我尝试通过 iOS 应用将照片发布到相册。我希望用户按他们的名字而不是页面所有者将他们的照片上传到粉丝页面的特定相册。
问题就像下面提到的问题:<br/>
<a href="https://stackoverflow.com/questions/19228423/post-a-photo-to-an-album-on-a-facebook-fan-page-without-being-the-admin" rel="noreferrer noopener nofollow">Post a photo to an Album on a Facebook fan page without being the admin,</a> <br/>
<a href="https://stackoverflow.com/questions/8677215/post-a-photo-to-a-page-for-ios" rel="noreferrer noopener nofollow">Post a photo to a page for iOS</a> </p>

<p>这是我发布照片的代码</p>

<pre><code>;
FBRequest *request1 = [FBRequest requestWithGraphPath:@&#34;v2.3/&lt;album-id&gt;/photos&#34;
                                           parameters:
                                           HTTPMethod:@&#34;POST&#34;];
</code></pre>

<p>我在哪里获得权限</p>

<pre><code>- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
   NSArray *permissions = [ initWithObjects:
                        @&#34;publish_actions&#34;,
                        @&#34;user_photos&#34;,
                        @&#34;email&#34;,
                        @&#34;user_likes&#34;,
                        @&#34;publish_pages&#34;,
                        nil];
   return [FBSession openActiveSessionWithPermissions:permissions
                                    allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                                          switch (status) {
                                              case FBSessionStateOpen:
                                                break;
                                              case FBSessionStateClosed:
                                                break;
                                              case FBSessionStateCreated:
                                                break;
                                              case FBSessionStateCreatedOpening:
                                                break;
                                              case FBSessionStateClosedLoginFailed:
                                                break;
                                              case FBSessionStateOpenTokenExtended:
                                                break;
                                              case FBSessionStateCreatedTokenLoaded:
                                                break;
                                          }

                                    }];
    }
</code></pre>

<p>当我开始请求时,我会收到错误,它说:</p>

<pre><code>code = 200
&#34;error_user_msg&#34; = You don&#39;t have permission to edit this photo or album.
&#34;error_user_title&#34; = &#34;Insufficient permissions&#34;                        
&#34;is_transient&#34; = 0                                                      
message = &#34;Permissions error&#34;
</code></pre>

<p>我已经阅读了文档,看起来你只需要 publish_actions 这个权限和专辑 ID,然后你就可以在专辑上发帖。但我刚刚收到错误。</p>

<p>当我将相册 ID 更改为页面 ID 时,它会起作用,但照片不属于任何相册。</p>

<p>是我遗漏了什么还是我误解了文件?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您似乎遇到了访问 token 问题。
为了发布到属于某个页面的相册,您需要使用页面访问 token 而不是用户访问 token :
根据 <a href="https://developers.facebook.com/docs/facebook-login/access-tokens" rel="noreferrer noopener nofollow">documentation</a> :</p>

<blockquote>
<p>Page Access Token – These access tokens are similar to user access tokens, except that they provide permission to APIs that read, write or modify the data belonging to a Facebook Page. To obtain a page access token you need to start by obtaining a user access token and asking for the manage_pages permission. Once you have the user access token you then get the page access token via the Graph API.</p>
</blockquote>

<p>您可以从 <a href="https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens" rel="noreferrer noopener nofollow">here</a> 了解如何获取页面 token 。 .</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - FB Api - 无法通过 IOS 应用将照片发布到页面的相册,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/29558943/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/29558943/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - FB Api - 无法通过 IOS 应用将照片发布到页面的相册