【问题标题】:Facebook App - Requires either publish_actions permission, or manage_pages and publish_pages as an admin with sufficient administrative permissionFacebook 应用程序 - 需要 publish_actions 权限,或 manage_pages 和 publish_pages 作为具有足够管理权限的管理员
【发布时间】:2018-09-11 00:55:05
【问题描述】:

该应用程序是公开的,并且已被授予适当的权限: Display of app permissions

我的登录用户是该应用的管理员:Display of user permissions

代码如下:

import facebook
import warnings



# Hide deprecation warnings. The facebook module isn't that up-to-date (facebook.GraphAPIError).
warnings.filterwarnings('ignore', category=DeprecationWarning)


# Parameters of your app and the id of the profile you want to mess with.
FACEBOOK_APP_ID     = 'SECRET'
FACEBOOK_APP_SECRET = 'SECRET'
FACEBOOK_PROFILE_ID = 'SECRET'

fb_api=facebook.GraphAPI()
api_token=fb_api.get_app_access_token(app_id=FACEBOOK_APP_ID, app_secret=FACEBOOK_APP_SECRET, offline=True)

graph = facebook.GraphAPI(api_token)
# Try to post something on the wall.
try:
    fb_response = graph.put_object(parent_object=FACEBOOK_PROFILE_ID, connection_name='feed',
                     message='Hello, world')
    print(fb_response)
except facebook.GraphAPIError as e:
    print('Something went wrong:', e.type, e.message)

此代码失败并显示错误消息: OAuthException (#200) 需要 publish_actions 权限,或 manage_pages 和 publish_pages 作为具有足够管理权限的管理员

在这一点上,我确信我已经遵循了我在任何其他帖子中读到的所有内容。他们为 sdk 提供的文档是 here。

【问题讨论】:

  • get_app_access_token 听起来你在这里得到的只是一个应用访问令牌。过去使用应用令牌发帖可能有效,但现在您需要使用用户或页面访问令牌。
  • 我将不得不安装 puppeteer 或 selenium,这就像超级跛脚
  • 也是不允许的,被抓到时可能会被屏蔽。如果您有合法的用例要发布,为什么不能获得合适的令牌?
  • 在宏伟的计划中它是不合法的。但它也不是恶意的或具有广泛影响的。如果推荐人是 facebook,许多网站允许以独特的方式访问它们。但它不仅仅是设置一个引用者,据我所知,它也不在链接参数中。它可能是唯一的密钥或设置在本地存储或某种 cookie 中的东西。这似乎是故意混淆的东西。虽然只需发布到 Facebook,然后点击链接,这应该很容易。应用程序无法做到这一点一定是最近才出现的,因为那里有很多教程。

标签: python facebook api facebook-graph-api


【解决方案1】:

一堆东西不起作用,所以这就是我所做的。我创建了一个链接,然后单击它: https://developers.facebook.com/docs/php/howto/example_facebook_login

使用 laravel 或 lumen 之类的东西非常简单。您只需创建一个控制器和一个指向它的路由。

我将令牌上传到本地领事实例,以便我可以跨各种微服务访问它。

我使用 puppeteer 通过我的存根网站登录 facebook,然后我也有一个令牌和登录 cookie。

【讨论】:

    【解决方案2】:

    我们发现 facebook 将发布到页面的权限要求从仅 manage_pages 更改为同时要求 manage_pages 和 publish_pages。通过授予这两个权限,我们解决了我们的问题

    本质上,我们必须将客户端传递给 https://www.facebook.com/dialog/oauth?client_id=client_id&redirect_uri=redirect_uri&scope=manage_pages,publish_pages&response_type=code%20token&enable_profile_selector=1&profile_selector_ids=pageid

    【讨论】:

      猜你喜欢
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多