脸书业务 |从 10->12 更新
facebook-business | Update from 10->12
有谁知道是什么导致了这个折旧问题(act_******** 技术上是一个实际数字,但在问题中隐藏了它)?
Message: Call was not successful
Method: POST
Path: https://graph.facebook.com/v10.0/act_*********/insights
Params: {'date_preset': 'today', 'action_attribution_windows': '["1d_click"]', 'level': 'ad', 'limit': '1000', 'status': '["ACTIVE"]', 'fields': '["account_id","account_name","action_values","actions","ad_id","ad_name","adset_id","adset_name","campaign_id","campaign_name","clicks","cpc","cpm","ctr","date_start","date_stop","impressions","inline_link_clicks","reach","spend","website_purchase_roas"]'}
我正在 运行ning 一个脚本,该脚本每小时从 EC2 实例向 FB Marketing API 发出请求。我使用以下软件包:
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.ad import Ad
from facebook_business.adobjects.adset import AdSet
from facebook_business.adobjects.user import User
from facebook_business.adobjects.campaign import Campaign
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adsinsights import AdsInsights
from facebook_business.adobjects.adreportrun import AdReportRun
并且已经更新到 12.0 版:
facebook-business 12.0.0
这是每小时 运行 的脚本:
if str(kwargs['timeframe']) == 'hourly':
# Looping through AdAccount ids:
for account in KEYS['ACCOUNT_IDs']:
print(f'Hourly calls - Loading account: {account}')
# Fetching ad insights without async on:
ads = AdAccount(account).get_insights(
params=kwargs['params'],
fields=kwargs['fields'],
is_async=True)
ads.api_get()
# While loop to verify that async is done:
while ads[AdReportRun.Field.async_status] != 'Job Completed':
time.sleep(1)
print(ads.api_get())
if ads[AdReportRun.Field.async_status] == 'Job Failed':
break
else:
continue
counter += 1
print(f'Daily active calls, counter: {counter}')
insights = str(ads.get_result(
params={"limit": 1000},
fields=ad_fields))
# Replacing extra string and converting into JSON:
df_normalized = json.loads(insights.replace('<AdsInsights>', ''))
print(f'Ad Insights: {df_normalized}')
# Appending response to main df:
df = df.append(df_normalized, ignore_index=True)
time.sleep(.75)
奇怪的是,如果我 运行 在我的笔记本电脑本地 运行 升级软件包后它会正常运行。我确实在“设置”->“高级”下更新了我的应用程序,以在升级所有调用和升级应用程序角色调用时使用版本 12.0。
我注意到我的 Path 仍在调用旧版本 (10.0),也许更新可以解决问题?如果是,我该如何更新?但是,为什么当 运行在我的笔记本电脑上本地时不调用它?
提前致谢!!
我的问题是 EC2 安装了 python2.7,但我从未更新默认值,因此在使用 pip 更新 facebook-business 时,它默认为 2.7 而不是使用 python 3.6。
我还必须更新 init class:
FacebookAdsApi.init(access_token= KEYS['ACCESS_TOKEN'], api_version='v12.0')
有谁知道是什么导致了这个折旧问题(act_******** 技术上是一个实际数字,但在问题中隐藏了它)?
Message: Call was not successful
Method: POST
Path: https://graph.facebook.com/v10.0/act_*********/insights
Params: {'date_preset': 'today', 'action_attribution_windows': '["1d_click"]', 'level': 'ad', 'limit': '1000', 'status': '["ACTIVE"]', 'fields': '["account_id","account_name","action_values","actions","ad_id","ad_name","adset_id","adset_name","campaign_id","campaign_name","clicks","cpc","cpm","ctr","date_start","date_stop","impressions","inline_link_clicks","reach","spend","website_purchase_roas"]'}
我正在 运行ning 一个脚本,该脚本每小时从 EC2 实例向 FB Marketing API 发出请求。我使用以下软件包:
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.ad import Ad
from facebook_business.adobjects.adset import AdSet
from facebook_business.adobjects.user import User
from facebook_business.adobjects.campaign import Campaign
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.adsinsights import AdsInsights
from facebook_business.adobjects.adreportrun import AdReportRun
并且已经更新到 12.0 版:
facebook-business 12.0.0
这是每小时 运行 的脚本:
if str(kwargs['timeframe']) == 'hourly':
# Looping through AdAccount ids:
for account in KEYS['ACCOUNT_IDs']:
print(f'Hourly calls - Loading account: {account}')
# Fetching ad insights without async on:
ads = AdAccount(account).get_insights(
params=kwargs['params'],
fields=kwargs['fields'],
is_async=True)
ads.api_get()
# While loop to verify that async is done:
while ads[AdReportRun.Field.async_status] != 'Job Completed':
time.sleep(1)
print(ads.api_get())
if ads[AdReportRun.Field.async_status] == 'Job Failed':
break
else:
continue
counter += 1
print(f'Daily active calls, counter: {counter}')
insights = str(ads.get_result(
params={"limit": 1000},
fields=ad_fields))
# Replacing extra string and converting into JSON:
df_normalized = json.loads(insights.replace('<AdsInsights>', ''))
print(f'Ad Insights: {df_normalized}')
# Appending response to main df:
df = df.append(df_normalized, ignore_index=True)
time.sleep(.75)
奇怪的是,如果我 运行 在我的笔记本电脑本地 运行 升级软件包后它会正常运行。我确实在“设置”->“高级”下更新了我的应用程序,以在升级所有调用和升级应用程序角色调用时使用版本 12.0。
我注意到我的 Path 仍在调用旧版本 (10.0),也许更新可以解决问题?如果是,我该如何更新?但是,为什么当 运行在我的笔记本电脑上本地时不调用它?
提前致谢!!
我的问题是 EC2 安装了 python2.7,但我从未更新默认值,因此在使用 pip 更新 facebook-business 时,它默认为 2.7 而不是使用 python 3.6。
我还必须更新 init class:
FacebookAdsApi.init(access_token= KEYS['ACCESS_TOKEN'], api_version='v12.0')