[请帮助我修复curl命令和python代码。我正在放置密钥,但无法获取CAMPAIGN_ID
。我已经为我的Facebook页面创建了一个广告,但是找不到CAMPAIGN_ID
,我尝试使用广告ID,但这也没有用。
curl -G \
-d "level=ad" \
-d "fields=impressions,ad_id" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/<CAMPAIGN_ID>/insights"
我也使用了下面的python代码,但出现了一些错误。
from facebook_business.objects import AdCampaign
campaign = AdCampaign('<AD_CAMPAIGN_ID>')
params = {
'date_preset': AdCampaign.Preset.last_7_days,
}
insights = campaign.get_insights(params=params)
print insights
下面是错误:
traceback (most recent call last): File "fbAds2.py", line 1, in <module> from facebook_business.objects import AdCampaign ModuleNotFoundError: No module named 'facebook_business.objects'```
我遇到相同的错误,所以我稍微更改了代码并得到了结果
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.campaign import Campaign
from facebook_business.api import FacebookAdsApi
app_id = 'zzzzzzzz'
app_secret = 'yyyyyyyy'
access_token = 'xxxxxxxxxxxxx'
campaign = Campaign('xxxxxxxx')
insights = campaign.get_insights()
print(insights)