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

时间:2018-12-14 10:48:26

标签: facebook-graph-api

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

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

  • manage_pages
  • pages_show_list
  • leads_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"
  }
}

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

6 个答案:

答案 0 :(得分:1)

在新的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,
]

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

答案 1 :(得分:0)

当我尝试为facebook_lead ads广告活动添加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'});

}     

答案 2 :(得分:0)

也许,这对你们有帮助:

https://developers.facebook.com/docs/graph-api/reference/page/subscribed_apps/#Creating

像这样的POST请求形式: https://graph.facebook.com/v3.2/me/subscribed_apps?subscribed_fields=

因此您需要创建它。 :)

我的权限有问题,这很奇怪,因为我在这里仔细检查了我的页面权限: https://developers.facebook.com/tools/debug/accesstoken 似乎我有fb错误响应消息中缺少的权限。

我得到了这个答复:

{
"error": {
    "message": "(#200) To subscribe to the feed field, one of these permissions is needed: manage_pages. To subscribe to the mention field, one of these permissions is needed: manage_pages. To subscribe to the name field, one of these permissions is needed: manage_pages. To subscribe to the picture field, one of these permissions is needed: manage_pages. To subscribe to the category field, one of these permissions is needed: manage_pages. To subscribe to the description field, one of these permissions is needed: manage_pages. To subscribe to the conversations field, one of these permissions is needed: manage_pages. To subscribe to the branded_camera field, one of these permissions is needed: manage_pages. To subscribe to the feature_access_list field, one of these permissions is needed: manage_pages. To subscribe to the standby field, one of these permissions is needed: manage_pages. To subscribe to the messages field, one of these permissions is needed: manage_pages. To subscribe to the messaging_account_linking field, one of these permissions is needed: manage_pages. To subscribe to the messaging_checkout_updates field, one of these permissions is needed: manage_pages. To subscribe to the message_echoes field, one of these permissions is needed: manage_pages. To subscribe to the message_deliveries field, one of these permissions is needed: manage_pages. To subscribe to the messaging_game_plays field, one of these permissions is needed: manage_pages. To subscribe to the messaging_optins field, one of these permissions is needed: manage_pages. To subscribe to the messaging_optouts field, one of these permissions is needed: manage_pages. To subscribe to the messaging_payments field, one of these permissions is needed: manage_pages. To subscribe to the messaging_postbacks field, one of these permissions is needed: manage_pages. To subscribe to the messaging_pre_checkouts field, one of these permissions is needed: manage_pages. To subscribe to the message_reads field, one of these permissions is needed: manage_pages. To subscribe to the messaging_referrals field, one of these permissions is needed: manage_pages. To subscribe to the messaging_handovers field, one of these permissions is needed: manage_pages. To subscribe to the messaging_policy_enforcement field, one of these permissions is needed: manage_pages. To subscribe to the messaging_page_feedback field, one of these permissions is needed: manage_pages. To subscribe to the messaging_appointments field, one of these permissions is needed: manage_pages. To subscribe to the founded field, one of these permissions is needed: manage_pages. To subscribe to the company_overview field, one of these permissions is needed: manage_pages. To subscribe to the mission field, one of these permissions is needed: manage_pages. To subscribe to the products field, one of these permissions is needed: manage_pages. To subscribe to the general_info field, one of these permissions is needed: manage_pages. To subscribe to the leadgen field, one of these permissions is needed: leads_retrieval. To subscribe to the leadgen_fat field, one of these permissions is needed: leads_retrieval. To subscribe to the location field, one of these permissions is needed: manage_pages. To subscribe to the hours field, one of these permissions is needed: manage_pages. To subscribe to the parking field, one of these permissions is needed: manage_pages. To subscribe to the public_transit field, one of these permissions is needed: manage_pages. To subscribe to the page_about_story field, one of these permissions is needed: manage_pages. To subscribe to the phone field, one of these permissions is needed: manage_pages. To subscribe to the email field, one of these permissions is needed: manage_pages. To subscribe to the website field, one of these permissions is needed: manage_pages. To subscribe to the ratings field, one of these permissions is needed: manage_pages. To subscribe to the attire field, one of these permissions is needed: manage_pages. To subscribe to the payment_options field, one of these permissions is needed: manage_pages. To subscribe to the culinary_team field, one of these permissions is needed: manage_pages. To subscribe to the general_manager field, one of these permissions is needed: manage_pages. To subscribe to the price_range field, one of these permissions is needed: manage_pages. To subscribe to the awards field, one of these permissions is needed: manage_pages. To subscribe to the hometown field, one of these permissions is needed: manage_pages. To subscribe to the current_location field, one of these permissions is needed: manage_pages. To subscribe to the bio field, one of these permissions is needed: manage_pages. To subscribe to the affiliation field, one of these permissions is needed: manage_pages. To subscribe to the birthday field, one of these permissions is needed: manage_pages. To subscribe to the personal_info field, one of these permissions is needed: manage_pages. To subscribe to the personal_interests field, one of these permissions is needed: manage_pages. To subscribe to the publisher_subscriptions field, one of these permissions is needed: manage_pages. To subscribe to the members field, one of these permissions is needed: manage_pages. To subscribe to the checkins field, one of these permissions is needed: manage_pages. To subscribe to the page_upcoming_change field, one of these permissions is needed: manage_pages. To subscribe to the page_change_proposal field, one of these permissions is needed: manage_pages. To subscribe to the merchant_review field, one of these permissions is needed: manage_pages. To subscribe to the product_review field, one of these permissions is needed: manage_pages. To subscribe to the videos field, one of these permissions is needed: manage_pages. To subscribe to the live_videos field, one of these permissions is needed: manage_pages. To subscribe to the registration field, one of these permissions is needed: manage_pages",
    "type": "OAuthException",
    "code": 200,
    "fbtrace_id": "HTI8+tPvJZt"
}

}

但我希望您可以避免此错误。 :)

答案 3 :(得分:0)

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

这是解决@AdityaChowdhary最初问题的方法:-添加“ subscribed_fields:'leadgen'”作为后置参数,如下所示:

def addlst(list_, item):
    """add an item to a list"""
    if isinstance(item, str):
        item = item.capitalize()
    list_.append(item)
    return list_

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

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

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

答案 4 :(得分:0)

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

DATETIME

答案 5 :(得分:0)

对于fb.login,您不能使用'manage_pages'作为范围,请尝试使用以下内容:

{scope: ['pages_show_list','leads_retrieval']}