Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve "The parameter subscribed_fields is required" error while subscribing a facebook page to app?

I am creating an app that will pull leads from facebook pages that I manage and update them into Google Sheets subsequently.

I have setup the webhook, generated long lived page access token with following permissions

  • manage_pages
  • pages_show_list
  • leads_retrieval
  • ads_management
  • ads_read

When I try to subscribe the page to my app using POST request {page_id}/subscribed_apps I get the below error

{
  "error": {
    "message": "(#100) The parameter subscribed_fields is required.",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "Fv7RbO8tYqo"
  }
}

Researching revealed that facebook has added a new parameter called subscribed_fields in v3.2 api, but I am not sure how values must be passed to that parameter or is there something I am missing?

like image 324
Aditya Chowdhary Avatar asked Dec 14 '18 10:12

Aditya Chowdhary


1 Answers

As of facebook api v3.2, I also ran into problems.

Here's what fixed @AdityaChowdhary's original issue: -add "subscribed_fields: 'leadgen'" as a post parameter, like this:

FB.api(
    '/' + page_id + '/subscribed_apps',
    'post',
      { access_token: page_access_token, subscribed_fields: 'leadgen' },
    function (response) {
        console.log('Successfully subscribed page', response);
    });

Then, you may run into another error: "To subscribe to the leadgen field, one of these permissions is needed: leads_retrieval".

To prevent the permissions error: add the "leads_retrieval" permission to the fb.login scope, like this:

FB.login(function (response) {
...
}, {scope: ['manage_pages', 'leads_retrieval']});
like image 84
Jonathan Harris Avatar answered Sep 28 '22 02:09

Jonathan Harris