Post 页面内容

Post content as a page

我正在尝试 post 将消息发送到企业页面的墙上。我遵循以下 steps 并且一切正常,只是我没有以管理员身份在业务墙上发布消息。

graph = facebook.GraphAPI(access_token='xxx')

如果我使用 graph.put_wall_post(message='test'),我会将文本发布在我的个人墙上。

使用业务页面的个人资料 ID,graph.put_wall_post(message='test', profile_id='5537xx') 我 post 类似于 Me > business page

如果我尝试使用业务页面创建应用程序,我会收到以下错误:

Users not logged into their personal account cannot access developers.facebook.com

如何 post 将消息作为文本 post 直接发送到我的业务页面而不出错?

你应该得到一个页面 access-token。您可能正在为您的个人帐户获取访问令牌。

如图表 API 文档中所述,here and here

With the Pages API, people using your app can post to Facebook as a Page (...)
Before your app can make calls to read, update, or post to Pages you need to get a page access token. With this token you can view Page settings, make updates to page information and manage a Page.

因此,您基本上应该获得与您的页面对应的令牌

To get the Page access token for a single page call the API endpoint /{page-id} using an user access token and asking for the field access_token. You need the permission pages_show_list or manage_pages to successfully execute this call.

然后请求 post 内容,例如一条消息

To post text to a Page's feed, provide a message parameter with the text along with the Page ID:

POST https://graph.facebook.com/546349135390552/feed?message=Hello

成功后,Graph API 响应 JSON 包含 Page

ID and the ID for the post:

{ "id": "546349135390552_1116689038356556" }

阅读上面的链接,您将获得更多相关信息。