向应用程序订阅Facebook页面时,如何解决“参数subscribed_fields是必需的”错误?

Adi*_*ary 7 facebook-graph-api

我正在创建一个应用程序,该应用程序将从我管理的Facebook页面中获取潜在客户,然后将其更新到Google表格中。

我已经设置了Webhook,使用以下权限生成了长寿命的页面访问令牌

  • manage_pages
  • pages_show_list
  • lead_retrieval
  • ads_management
  • ads_read

当我尝试使用POST请求将页面订阅到我的应用程序时{page_id}/subscribed_apps,出现以下错误

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

研究表明,facebook在v3.2 api中添加了一个名为subscribed_fields的新参数,但是我不确定如何将值传递给该参数,或者我缺少什么?

Jon*_*ris 8

从 facebook api v3.2 开始,我也遇到了问题。

这是修复@AdityaChowdhary 的原始问题的内容: -add "subscribed_fields: 'leadgen'" 作为帖子参数,如下所示:

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

然后,您可能会遇到另一个错误:“要订阅 Leadgen 字段,需要以下权限之一:leads_retrieval”。

为防止权限错误:将“leads_retrieval”权限添加到 fb.login 范围,如下所示:

FB.login(function (response) {
...
}, {scope: ['manage_pages', 'leads_retrieval']});
Run Code Online (Sandbox Code Playgroud)


Viv*_*vek 8

在新的 Graph API v3.2 中,您必须subscribed_fieldspost请求一起传递参数me/subscribed_apps(使用页面访问令牌作为访问令牌)。您需要传递一组可用的可订阅字段,它们是:

[
    feed, mention, name, picture, category, description, conversations,
    branded_camera, feature_access_list, standby,
    messages, messaging_account_linking, messaging_checkout_updates,
    message_echoes, message_deliveries, messaging_game_plays, messaging_optins,
    messaging_optouts, messaging_payments, messaging_postbacks,
    messaging_pre_checkouts, message_reads, messaging_referrals,
    messaging_handovers, messaging_policy_enforcement,
    messaging_page_feedback, messaging_appointments, founded,
    company_overview, mission, products, general_info, leadgen,
    leadgen_fat, location, hours, parking, public_transit,
    page_about_story, phone, email, website, ratings, attire,
    payment_options, culinary_team, general_manager, price_range,
    awards, hometown, current_location, bio, affiliation, birthday,
    personal_info, personal_interests, publisher_subscriptions, members,
    checkins, page_upcoming_change, page_change_proposal,
    merchant_review, product_review, videos, live_videos, registration,
]
Run Code Online (Sandbox Code Playgroud)

比如: subscribed_fields: ['messages', 'message_deliveries']


Abh*_*602 6

在请求中添加subscribed_fields=publisher_subscriptions对我有用。
这是代码:

request({
        method: 'POST',
        uri: `https://graph.facebook.com/v2.6/me/subscribed_apps?subscribed_fields=publisher_subscriptions&access_token=${FB_PAGE_ACCESS_TOKEN}`
        },
        (error, response, body) => {
             if (error) {
                console.error('Error while subscription: ', error);
             } else {
                 console.log('Subscription result: ', response.body);
             }
       });
Run Code Online (Sandbox Code Playgroud)


Sol*_*ent 1

当我尝试为 facebook_lead 广告活动添加 webhook 时,我遇到了同样的问题...它曾经在以前的版本上完美运行,我传递了范围:“manage_pages”

function myFacebookLogin() {
FB.login(function(response){
  console.log('Successfully logged in', response);
  FB.api('/me/accounts', 
    {limit: 200}, 
    function(response) {
    console.log('Successfully retrieved pages', response);
    var pages = response.data;
    var ul = document.getElementById('list');
    for (var i = 0, len = pages.length; i < len; i++) {
      var page = pages[i];
      var li = document.createElement('li');
      var a = document.createElement('a');
      a.href = "#";
      a.onclick = subscribeApp.bind(this, page.id, page.access_token);
      a.innerHTML = page.name;
      li.appendChild(a);
      ul.appendChild(li);
    }
  });
}, {scope: 'manage_pages'});
Run Code Online (Sandbox Code Playgroud)

}