0

我正在使用 facebookads python api,v2.6。

我正在尝试创建一个优化目标 = Lead_generation 的 AdSet。

这是我的代码:

ad_set = AdSet(parent_id = 'act_%s' % FB_ACCOUNT)
ad_set[AdSet.Field.name]= 'Teste AdSet'
ad_set[AdSet.Field.campaign_id]='6043402838999'
ad_set[AdSet.Field.status]=AdSet.Status.paused
ad_set[AdSet.Field.billing_event] = AdSet.BillingEvent.impressions
ad_set[AdSet.Field.optimization_goal] = AdSet.OptimizationGoal.lead_generation
ad_set[AdSet.Field.daily_budget]= 100
ad_set[AdSet.Field.bid_amount]= 1
ad_set[AdSet.Field.start_time]= '2016-07-01'
ad_set[AdSet.Field.promoted_object]= 
ad_set[AdSet.Field.targeting]= {Targeting.Field.geo_locations: { 'countries': ['BR']},Targeting.Field.genders: [1],Targeting.Field.age_min: 20,Targeting.Field.age_max: 24}

ad_set.remote_create()

但是当我运行它时,我得到了这个错误:

 Status:  400
  Response:
    {
      "error": {
        "code": 100,
        "is_transient": false,
        "error_subcode": 1885024,
        "error_user_msg": "When creating an ad set within a campaign using the Body of an error/warning message. Title is: Promoted Object Missing objective, a promoted object must be specified.",
        "error_user_title": "Promoted Object Missing",
        "message": "Invalid parameter",
        "type": "OAuthException",
        "fbtrace_id": "B9hyZlpzS7O"
      }
    }

我试图找到有关此的任何文档,但找不到。在官方文档中,我没有在提升的对象选项上看到 LEAD_GENERATION:

https://developers.facebook.com/docs/marketing-api/reference/ad-campaign#Creating

有人遇到过这个问题吗?

4

3 回答 3

0

广告集必须将其promoted_object 设置为相应的<PAGE_ID>.

参考: https ://developers.facebook.com/docs/marketing-api/guides/lead-ads/create#create

于 2016-06-16T06:23:10.967 回答
0

您必须指定关联的 page_id

promoted_object={"page_id": "<PAGE_ID>"}

下面的代码可以帮助你

from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adset import AdSet
from facebook_business.api import FacebookAdsApi

access_token = '<ACCESS_TOKEN>'
app_secret = '<APP_SECRET>'
app_id = '<APP_ID>'
id = '<AD_ACCOUNT_ID>'
FacebookAdsApi.init(access_token=access_token)

fields = [
]
params = {
  'name': 'A CPA Ad Set',
  'campaign_id': '<adCampaignLinkClicksID>',
  'daily_budget': '5000',
  'start_time': '2019-01-09T21:31:19-0800',
  'end_time': '2019-01-16T21:31:19-0800',
  'billing_event': 'IMPRESSIONS',
  'optimization_goal': 'REACH',
  'bid_amount': '1000',
  'promoted_object': {'page_id':'<pageID>'},
  'targeting': {'geo_locations':{'countries':['US']}},
  'user_os': 'iOS',
  'publisher_platforms': 'facebook',
  'device_platforms': 'mobile',
}
print AdAccount(id).create_ad_set(
  fields=fields,
  params=params,
)
于 2019-02-12T11:17:34.407 回答
0

如果有人有同样的问题,你必须使用page_id.

于 2016-06-15T16:50:39.840 回答