As we all know, inside the Facebook for Developers interface, you can add Facebook Pages to a Facebook App as in the picture below and generate the Page Access Token.
I'm trying to do this programmatically via the API requests. Unfortunately, I did not find in the documentation of the request how to do this.
What have I done so far?
- I can get the
User IDandUser Access TokenviaFacebook Login(Documentation). - I can get the list of
Facebook Pagesthat a person owns. In the response, I have thePage IDand thePage Access Token(Documentation). - I have the Facebook app that is in development mode. That app has
App IDandApp Secret. With these values, I can get theApp Access Token(Documentation). - I can set
Webhookto the Facebook App withApp IDandApp Access Token(Documentation). - I can set the
Webhook Subscriptions Fieldsfor my Facebook App (Documentation).
Question: What kind of API request should I use to add a Facebook Page to the Facebook App?
The list of my requests:
- I take
Page IDandPage Access Tokenwith this GET request cause this request returns the list ofFacebook Pagesthat a person owns:
https://graph.facebook.com/v9.0/{user-id}/accounts?access_token={user-access-token}
- I set the
Webhookin myFacebook Appwith thisPOSTrequest:
It successfully works and I see this Webhook in the "Webhooks" block of the Dashboard interface.
- Then I make this POST request to set
Webhook Subscriptions Fields:
In this request, I use Page ID and Page Access Token from the first step.
Unfortunately, I have such an error message:
To subscribe to the messages field, one of these permissions is needed: pages_messaging

