I'm trying to create Ad-set using the code given in developer's site. Here is link
Code:
from facebookads.adobjects.adset import AdSet
from facebookads.adobjects.targeting import Targeting
adset = AdSet(parent_id='act_Account-ID')
adset.update({
AdSet.Field.name: 'My Ad Set',
AdSet.Field.campaign_id: 'Campaingn-ID',
AdSet.Field.daily_budget: 1000,
AdSet.Field.billing_event: AdSet.BillingEvent.impressions,
AdSet.Field.optimization_goal: AdSet.OptimizationGoal.reach,
AdSet.Field.bid_amount: 2,
AdSet.Field.targeting: {
Targeting.Field.geo_locations: {
'countries': ['US'],
},
},
})
adset.remote_create(params={
'status': AdSet.Status.paused,
})
print(adset)
Error:
WARNING:root:parent_id as a parameter of constructor is being deprecated.
Traceback (most recent call last):
File "adset_test.py", line 88, in <module>
'status': AdSet.Status.paused,
File "D:\PERSONAL DATA\python\Online Compitions\Job Test\AbsentiaVR\env\lib\site-packages\facebookads\adobjects\abstractcrudobject.py", line 296, in remote_create
response = request.execute()
File "D:\PERSONAL DATA\python\Online Compitions\Job Test\AbsentiaVR\env\lib\site-packages\facebookads\api.py", line 669, in execute
response = self._api.call(
AttributeError: 'NoneType' object has no attribute 'call'
Note:
I have used right values in act_Account-ID
and 'Campaingn-ID'
.
Please help to solve this issue. Thanks in advance.
Apparently, that python client for their API has been deprecated and this is to be used now.
Initialising the API before instantiating the AdSet
object should not result in that issue:
from facebook_business.api import FacebookAdsApi
my_app_id = 'your-app-id'
my_app_secret = 'your-appsecret'
my_access_token = 'your-page-access-token'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)