-1

I am trying to post a message to the wall of a business page. I follow the following steps and everything works fine except that I don't publish the message on the business wall as administrator.

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

If I use graph.put_wall_post(message='test') I publish the text on my personal wall.

With the profile id of business page, graph.put_wall_post(message='test', profile_id='5537xx') I post something like Me > business page

If I try to create the app using the business page, I get the following error:

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

How can I post the message as a text post directly to my business page without error?

Community
  • 1
  • 1
anvd
  • 3,997
  • 19
  • 65
  • 126

1 Answers1

1

You should get an access-token for a page. You are probably getting an access-token for your personal account.

As stated in the Graph API Docs, 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.

Therefore, you basically should get the token corresponding to your 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.

And then make requests to post content, for instance, a message

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

On success, Graph API responds with JSON containing the Page

ID and the ID for the post:

{ "id": "546349135390552_1116689038356556" }

Read the links above and you'll have more information about it.

rafaelc
  • 57,686
  • 15
  • 58
  • 82