facebook / facebook-python-business-sdk

Python SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
1.33k stars 645 forks source link

update AdSet status only works using "status" field which was removed in v2.5 #113

Closed iditgolden closed 9 years ago

iditgolden commented 9 years ago

AdSet status can be changed only by adding "status" key to the adset obj but this field was replaced by configured_status in version 2.5. changing the configured_status does not update the adset status, only "status" (which no longer exist in the Field attributes of AdSet)

iditgolden commented 9 years ago

same thing with updating Campaign

paulbain commented 9 years ago

you should checkout the examples in our documentation. You set the status by passing it in a dictionary when calling the remote_create/update/save functions:

from facebookads.objects import Campaign

campaign = Campaign(parent_id='act_<AD_ACCOUNT_ID>')
campaign.update({
    Campaign.Field.name: 'My First Campaign',
    Campaign.Field.objective: '<OBJECTIVE>',
})

campaign.remote_create(params={
    'status': Campaign.Status.paused,
})
print(campaign)
iditgolden commented 9 years ago

@paulbain: yes, but there is no "status" attribute anymore in adSet and Campaign objects's Fields, only "configured_status" and "effective_status". so from what i understand from the new api, the configured_status should be updated

campaign.remote_create(params={
   'configured_status': Campaign.Status.paused,
})

there is no documentation on this "status" field. for example, this is the list of AdSet fields, and status is not one of them.

class Field(HasBidInfo, object):
        account_id = 'account_id'
        adlabels = 'adlabels'
        bid_amount = 'bid_amount'
        bid_info = 'bid_info'
        billing_event = 'billing_event'
        budget_remaining = 'budget_remaining'
        campaign_id = 'campaign_id'
        adset_schedule = 'adset_schedule'
        configured_status = 'configured_status'
        created_time = 'created_time'
        creative_sequence = 'creative_sequence'
        daily_budget = 'daily_budget'
        effective_status = 'effective_status'
        end_time = 'end_time'
        id = 'id'
        is_autobid = 'is_autobid'
        lifetime_budget = 'lifetime_budget'
        lifetime_imps = 'lifetime_imps'
        name = 'name'
        optimization_goal = 'optimization_goal'
        product_ad_behavior = 'product_ad_behavior'
        pacing_type = 'pacing_type'
        promoted_object = 'promoted_object'
        rf_prediction_id = 'rf_prediction_id'
        rtb_flag = 'rtb_flag'
        start_time = 'start_time'
        targeting = 'targeting'
        updated_time = 'updated_time'
paulbain commented 9 years ago

You need to read the configured_status and effective_status, yet update the configured_status field by passing a parameter called status when making an update.

Does that answer your question?

iditgolden commented 9 years ago

@paulbain: yes thank you, but why there is no "status" field in the Field attributes? status = 'status'

paulbain commented 9 years ago

it's because the object does not have a field call status, check the set of fields in the documentation: https://developers.intern.facebook.com/docs/marketing-api/reference/ad-campaign-group

Status is now separated into the two fields, the configured_status and effective_status. The write path uses a parameter which is not part of the object to set the configured_status.

iditgolden commented 9 years ago

@paulbain : thank you for your response. the link isn't available though.

hockeybuggy commented 8 years ago

Hey @iditgolden Are you sure that it should be configured_status? We are having some issues related to this. I think the link @paulbain was trying to post was:

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

The example there is verbatim what @paulbain said above. You're right that only effective_status and configured_status is listed in the "Reading" parameters table but, you can also see status in the table of parameters in the "Creating" and "Updating" sections.

paulbain commented 8 years ago

Yes you write the status field using the parameter status but you read it using both configured_status being what you set, and effective_status is what it's considered as due to other configuration of your ads. Hopefully we can make writing effective_status work at some point for consistency.

hockeybuggy commented 8 years ago

I created PR #147 that should add the status field to the effected objects. @iditgolden @paulbain Would you mind taking a look? :smile: