Error: 'NoneType' object has no attribute 'call'

Error: 'NoneType' object has no attribute 'call'

我正在尝试使用开发者网站中提供的代码创建广告集。这里是link

代码:

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)

错误:

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'

注:

我在 act_Account-ID'Campaingn-ID' 中使用了正确的值。

请帮忙解决这个问题。提前致谢。

显然,他们 API 的 python 客户端已被弃用,现在将使用 this

在实例化 AdSet 对象之前初始化 API 不应导致该问题:

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)