majkoz0rd
majkoz0rd

Reputation: 31

Facebook Messenger - add pages to my facebook app

I'm developing app which allows me to chat with customers via messenger. I'm chatting as a Page. I had to add that page into Facebook app -> Messenger -> Settings -> Access Token. It all works fine but is there any way to make that via API? I wanna add more pages on which I'm not admin. In fact I wanna allow admins to add theirs pages using my app.

Upvotes: 0

Views: 106

Answers (1)

Sarkar
Sarkar

Reputation: 1899

Yes you can do that and this is the process

1: First thing first you will make a facebook login button with this scope pages_show_list when user clicks on it he/she can select as many page as he want, after the login flow completed you should have a App-Scoped User Access Token

2: since you had the pages_show_list scope when user signed in you now have the ability to call to this endpoint using the user access token graph.facebook.com/me/accounts?fields=name,access_token&access_token=[USER ACCESS TOKEN] after requesting for this endpoint you will get a list of the pages that the user was selecting in the login flow and you now will see that in the response you have name and access_token for each page

3: grab an access token of the page you want and post to this endpoint graph.facebook.com/{page-id}/subscribed_apps?subscribed_fields=feed,[and any other fields you want to subscribe to]&access_token=[USE THE PAGE ACCESS TOKEN]

after that you should get a success response and now your app is subscribed to the Facebook page

Upvotes: 0

Related Questions