Posts tagged with facebook-marketing-api

There seems to be a bug in the facebook marketing api v20.0

When you try to create AdSet with IMPRESSION as an optimization goal for the campaign objective as OUTCOME_TRAFFIC, the api always returns

{ "error": { "message": "Invalid parameter", "type": "OAuthException", "code": 100, "error_data": "{"blame_field_specs":[["optimization_goal"]]}", "error_subcode": 2490408, "is_transient": false, "error_user_title": "Performance goal isn't available", "error_user_msg": "You can't use the selected performance goal with your campaign objective. Please select a different goal or edit your campaign.", "fbtrace_id": "AemKqGCO7_RymPyjuXcJJYp" } }

I tried from both facebook business sdk of v20.0 and using graph url v20.0

https://graph.facebook.com/v20.0/act_12xxxxxxxx/adsets?access_token=EAAwpjCkZBW7YBO4CSJex2ek2whxxxxxxxxxxxxxxxxx

There is no problem with v19.0 and v18.0

Has anyone came across this problem?

Recently we implemented a feature which integrates with the Facebook Conversion API. We have successfully completed the business verification, "Tech Provider" verification, and app review for advanced access to the ads_read permission. We've also configured the "Facebook Login for Business", according to the guides provided in the documentation. Even though all verification passed successfully before configuring the login flow we were getting the error:

"error":{"message":"Unsupported post request. Object with ID 'XXXXXXXXXXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation. 

After configuring the "Facebook Login for Business", according to the guides provided in the documentation, we encountered the following error:

"message":"(#270) This Ads API request is not allowed for apps with development access level (Development access is by default for all apps, please request for upgrade). Make sure that the access token belongs to a user that is both admin of the app and admin of the ad account." 

Upon reviewing the error message and documentation, we determined that to send successful events to the Facebook Conversion API, we might need to request "Ads Management Standard Access" to upgrade our "Marketing API" product from development mode (correct me if I am wrong). It is mentioned that we need more than 1,500 successful requests to qualify for this permission. Despite making over 6,000 successful events received in a test dataset, our requests for this feature have been repeatedly rejected with the following message:

Our records do not show a sufficient number of successful Ads API calls in the last 30 days by this application. It is required that the application successfully integrate with the Ads API before it is approved for Ads API Standard Access. Please review the criteria listed here for more information. Our records show that the error rate for Ads API calls in the last 30 days by this application is too high. It is required that the application have a sufficiently low error rate before it is approved for Ads API Standard Access.  

Could someone provide insights into the expected requests for granting permission to our app? Specifically, should these requests be directed to the Conversion API and include real data, such as actual Facebook click IDs? A detailed description of the required requests for us to achieve "Ads Management Standard Access" would be highly appreciated.

Additionally, if there are any other configuration or permission requirements needed for our app to send events via the Conversion API, beyond those we already have, that information would also be very helpful.

I am getting the following error from the below code and I can't seem to work out what exactly i am not doing right, I feel as though I am specifying the correct account IDs but it isn't being accepted.

import hashlib import hmac import sys sys.path.append('./.venv/lib/python3.12/site-packages') # Replace this with the place you installed facebookads using pip sys.path.append('./.venv/lib/python3.12/site-packages/facebook_business-3.0.0-py2.7.egg-info') # same as above from facebook_business.api import FacebookAdsApi from facebook_business.adobjects.adaccount import AdAccount my_app_id = '995427558947840' my_app_secret = '04765ed9281612e2aa8723935a7e4ad2' my_access_token = 'EAAVuWk8drdWkBOw5gCusNtZCxbwej5AIQdBsVhug4SZCneZCU95y2LgIyd5ulE8JC2KMfoyVYdxF5CZBrvyZCp6vYJzhApftZBp9Y4Lt0TtkRcOsTJmOE2AZBGbrbJcpn6ZAqXzyqTloLqrFSohRb6gBTz5KVI1m0VU7qLTCuZBMvNlTZBw5CiwbBQZBLGYh98rht0q3N7gPdJgunZCrVZAjWFeZCsYc2ZCvRCAZD' app_secretproof = hmac.new(bytes(my_access_token,'utf-8'),bytes(my_app_secret,'utf-8'),hashlib.sha256 ).hexdigest() FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token, app_secretproof) account = AdAccount('act_229199089180260') campaigns = account.get_campaigns() print(campaigns) 

Account ID provided in FacebookAdsApi.set_default_account_id expects a string that begins with 'act_'

I expect this code to bring me back all the campaigns in my given Facebook Ad account

I am using meta business suite leads center screen to manage potential candidates. But I want to write a tool to export the information on the screen of each candidate such as label, Assigned to, Stage.. to save to a separate database system.

Leads center image

I also know the api below can get basic information, but it seems to need ad_id, form_id. Although I am not using any ad at the moment. Can it be solved using webhook?

https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving

I'm trying to fetch insights for my ad sets using the Facebook Graph API. Here are the parameters and the request I'm making:

params_insights_get = {     "access_token": "ACCESS_TOKEN",     "level": "adset",     "fields": "reach,impressions,estimated_ad_recall_rate,frequency,full_view_impressions,full_view_reach,clicks,inline_link_clicks,outbound_clicks,video_play_retention_0_to_15s_actions,video_play_retention_20_to_60s_actions,actions,spend,instagram_upcoming_event_reminders_set,inline_link_click_ctr,outbound_clicks_ctr,unique_inline_link_clicks,cost_per_ad_click,cost_per_conversion,cost_per_one_thousand_ad_impression,cost_per_outbound_click,cost_per_thruplay,cost_per_unique_action_type,cost_per_unique_click,cost_per_unique_inline_link_click,cost_per_unique_outbound_click,cost_per_action_type,cpc,cpm,cpp,ctr,optimization_goal,adset_id,adset_name", } root_url = f"https://graph.facebook.com/v19.0/" campaigns_ext = "/campaigns" adsets_ext = "/adsets" insights_ext = "/insights" response_insights_get = requests.get(     root_url + campaign_id + insights_ext, params=params_insights_get ) 

This was working fine for the last six months. However, recently, I keep getting the following error response:

{     "error": {         "message": "Service temporarily unavailable",         "type": "OAuthException",         "is_transient": False,         "code": 2,         "error_subcode": 1504018,         "error_user_title": "Your request timed out",         "error_user_msg": "Please try a smaller date range, fetch less data, or use async jobs",         "fbtrace_id": "AvoEH7ogR7jlllCmCC943cH",     } } 

The date range I need is 7 days, i.e. the default value, and I need all the data in the query. I've tried async jobs, but the jobs keep failing. Interestingly, this only affects one particular campaign in my sample adaccount, the others work fine.