使用facebook ads sdk 2.5.1(python)尝试获取adset时未出现的字段

时间:2016-05-03 08:11:47

标签: facebook-graph-api facebook-php-sdk facebook-ads-api

以下是尝试获取给定广告ID的字段的代码。 问题是我无法获得我提到的任何领域。响应中只显示id。

代码:

FacebookAdsApi.init(account_id, "credentials", "access_token")

api = FacebookAdsApi.get_default_api()
api_batch = api.new_batch()

adset = AdSet(fbid=adset_id)
fields = [
    AdSet.Field.name,
    AdSet.Field.configured_status,
    AdSet.Field.effective_status,
    AdSet.Field.account_id,
    AdSet.Field.campaign_id,
    AdSet.Field.daily_budget,
    AdSet.Field.start_time,
    AdSet.Field.bid_amount,
    AdSet.Field.billing_event,
    AdSet.Field.optimization_goal,
    AdSet.Field.targeting,
    AdSet.Field.promoted_object
]

adset = AdSet(str(adset_id))

api = FacebookAdsApi.get_default_api()
api_batch = api.new_batch()

def get_response(success_adset=None):
    print "Response is success"
    print success_adset.json()

def get_failure(failure_adset=None):
    print "Response is failure"
    print failure_adset.json()

fn_success = partial(get_response)
fn_failure = partial(get_failure)

adset.remote_read(fields=[AdSet.Field.name], batch=api_batch, success=fn_success, failure=fn_failure)
api_batch.execute()

1 个答案:

答案 0 :(得分:1)

看起来你并没有将字段传递给remote_read方法。在SDK示例中,我们使用以下内容:

adset.remote_read(fields=[
    AdSet.Field.name,
    AdSet.Field.configured_status,
    AdSet.Field.effective_status,
    AdSet.Field.account_id,
    AdSet.Field.campaign_id,
    AdSet.Field.daily_budget,
    AdSet.Field.start_time,
    AdSet.Field.bid_amount,
    AdSet.Field.billing_event,
    AdSet.Field.optimization_goal,
    AdSet.Field.targeting,
    AdSet.Field.promoted_object
], batch=api_batch, success=fn_success, failure=fn_failure)