[英]FacebookRequestError while trying to retrieve Campaign Insight Data via Facebook Marketing API with Python/Django
我正在嘗試使用Python Business SDK通過Facebook的Marketing API獲得Campaign Insights,並且得到了FacebookRequestError:
Message: Call was not successful
Method: GET
Path: https://graph.facebook.com/v3.1/2603111949730990/insights
Params: {}
Status: 400
Response:
{
"error": {
"message": "Error accessing adreport job.",
"type": "OAuthException",
"code": 2601,
"error_subcode": 1815107,
"is_transient": true,
"error_user_title": "Loading Async Ads Report Failed",
"error_user_msg": "Sorry, the report cannot be loaded successfully. Please check if your job status is completed instead of failed or running before fetching the data.",
"fbtrace_id": "BQJsdi3g5tX"
}
}
我已經嘗試通過檢查作業狀態是否不是“作業完成”並且作業完成百分比小於100,但問題仍然存在,試圖修改wait_for_async_job()函數的代碼。
def wait_for_async_job(async_job):
async_job.remote_read()
while async_job[AdReportRun.Field.async_status] != 'Job Completed' and async_job[AdReportRun.Field.async_percent_completion] < 100:
time.sleep(1)
async_job.remote_read()
任何幫助將非常感激。 先感謝您!
我們已經解決了這個問題,問題在於wait_for_async_job中的while條件。 只要有至少一個條件為True,就應該有一個“ OR”運算符而不是“ AND”運算符,以便循環進行迭代。 這樣,我們檢查async_status是否都應為“ Job Completed”,並且完成百分比應為100。如果有人覺得有幫助,我將在此處保留答案。
def wait_for_async_job(async_job):
async_job.remote_read()
while async_job[AdReportRun.Field.async_status] != 'Job Completed' or async_job[AdReportRun.Field.async_percent_completion] < 100:
time.sleep(1)
async_job.remote_read()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.