无法使用应用令牌 post 到 Facebook 页面

Unable to post to facebook page using app token

我正在构建我的第一个 Facebook 应用程序,但遇到了一个问题。

任务 :构建一个完全服务器端的应用程序,供 facebook 页面的管理员使用到页面上的 post videos/photos。这不应涉及让管理员每次都登录以生成用户访问和页面访问令牌。

What I found : 根据要求,我发现 app tokens 可以用于此目的。这行特别暗示了它的用处。

App access tokens can also be used to publish content to Facebook on behalf of a person who has granted an open graph publishing permission to your application

我认为使用它是安全的,因为我的是一个完全服务器端的应用程序。

问题 文档说:

GET /oauth/access_token? client_id={app-id} &client_secret={app-secret} &grant_type=client_credentials

将提供可用于代替用户访问令牌的应用令牌。 但是,我无法这样做。具体遇到的错误是 错误 200。用户必须接受 TOS。由于我已经尝试使用 页面访问令牌 发布内容,我知道这是一个权限问题。

下面一行

a person who has granted an open graph publishing permission to your application.

并没有说明一切。我遇到了a related question,但答案似乎有点模糊。

如果有人能告诉我如何实现这一点,那就太好了。

为了post到一个页面,您至少需要授权manage_pages权限。如果你想post "as user",你需要添加publish_actions并使用"User Access Token"。如果你想post "as page",你需要添加publish_pages并使用"Page Access Token".

有关如何生成这些令牌的信息:

关于 TOS 的错误消息已经讨论过很多次了,请转到那些线程(或使用搜索功能找到更多):

  • (OAuthException) (#200) User must have accepted TOS on C# - Facebook
  • How come I get a "must have accepted TOS" error for test users with app installed?
  • facebook long term token "(#200) User must have accepted TOS"
  • Occassional (OAuthException - #200) (#200) User must have accepted TOS

您不能通过应用访问令牌post 访问页面。

的文档中明确说明了这一点
  • A user access token with publish_actions permission can be used to publish new posts on behalf of that person. Posts will appear in the voice of the user.
  • A page access token with publish_pages permission can be used to publish new posts on behalf of that page. Posts will appear in the voice of the page.

我建议使用永久页面访问令牌,因此没有义务更新用户访问令牌。在这里看看我的回答:

  • Post to a facebook page without "manage_pages" permission using php