以下是尝试获取给定广告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()
答案 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)