facebook_business.adobjects.business.Business get_ad_network_analytics() ERROR
WendyE opened this issue · 3 comments
facebook_business.adobjects.business.Business get_ad_network_analytics() ERROR
I‘m get data from https://graph.facebook.com/v18.0/{app_id}/adnetworkanalytics with params:
{'metrics': '["FB_AD_NETWORK_REVENUE"]', 'breakdowns': '["APP","COUNTRY","PLACEMENT"]', 'aggregation_period': 'DAY', 'since': '2024-01-16', 'until': '2024-01-17', 'limit': 2000}
then,I get the first page response paging like this:
{'cursors': {'before': 'MTM3OAZDZD', 'after': 'MTM3NwZDZD'}, 'next': '{next_url}'}
and get the last page response paging like this:
{'cursors': {'before': 'MTM3OAZDZD', 'after': 'MTM3NwZDZD'}, 'previous': '{previous_url}'}
BUT, Business.get_ad_network_analytics() will infinite loop to request the last page!!!
Finally,I got response:
Status: 400
Response:
{
"error": {
"message": "(#613) You can have at most 250 queries per minute",
"type": "OAuthException",
"code": 613,
"fbtrace_id": "AXh2zHUPkO8EALtDlsgV1RR"
}
}
I debug the facebook_business code,find the code in facebook_business.api load_next_page() line 835:
if (
'paging' in response and
'cursors' in response['paging'] and
'after' in response['paging']['cursors']
):
self.params['after'] = response['paging']['cursors']['after']
else:
# Indicate if this was the last page
self._finished_iteration = True
if condition always stand up!because response['paging']['cursors']['after'] always true!
Now, what can I do to resolve this problem?
thanks for reporting this bug. we will provide a fix in our next release to instead check the existence of 'next'
in response['paging']
to decide if it is the last page.
OK!thanks!