Posts tagged with facebook-business-sdk

From Facebook document: https://www.facebook.com/business/help/652738434773716 "You can have up to 5,000 ads. Only 1,000 of these 5,000 ads can use dynamic creative."

Some my adaccounts have an issue "Your account xxxx has reached the maximum number of dynamic creative ads allowed (1,000). Please delete some of your older ads."

How can I count ads that are using "dynamic creative"? Note: I can count ads by

        $adAccount = new AdAccount($adAccountId);         $cursor = $adAccount->getAds(             params: [                 'date_preset' => 'today',                 'summary' => 'total_count',                 'limit' => 1,             ]         ); 

It is great if I can find an API to get numbers ads use dynamic creative belong to each adaccount

I have created this code to fetch leads from Facebook:

import pandas as pd from facebook_business.api import FacebookAdsApi from facebook_business.adobjects.adaccount import AdAccount from facebook_business.adobjects.ad import Ad from facebook_business.adobjects.user import User from facebook_business.adobjects.lead import Lead import requests from datetime import datetime import time # Permanent Access Token access_token = "my_token" facebook_api = FacebookAdsApi.init(access_token=access_token) start_date = '2023-07-01'  end_date = '2023-07-31'  account_id = "my_ad_account_id" lead_fields = ['campaign_name',"created_time","field_data"] lead_params = {                 'filtering': [{'field': 'time_created', 'operator': 'GREATER_THAN', 'value': start_date},                               {'field': 'time_created', 'operator': 'LESS_THAN', 'value': end_date}                              ]               } leads_list = [] # Getting ads ad_account = AdAccount(account_id) ads = ad_account.get_ads() for ad in ads:   leads = ad.get_leads(fields=lead_fields,params=lead_params)   for lead in leads:     lead_dic = {}     lead_dic["campaign_name"] = lead["campaign_name"]     lead_dic["created_time"] = lead["created_time"]     field_data = lead["field_data"]     for field in field_data:       lead_dic[field["name"]] = field["values"][0]     leads_list.append(lead_dic) print(leads_list) 

It works for my test account that has few ads, but I get an limit error when I try to use it with my main account.

I figure that I should use batch request, but I could not make it work. Can someone please help to to adapt this code so it does not get limit errors?

I am using python sdk facebook_bussiness for acceissng meta apis. So when we create ad we have to choose the call to action depending on the type of media uploaded if media is an image then CTA would be differnet and diffirent for Videos. My questions is there any endpoint/function in the sdk which return me the CTAs depending on the media type, so that I don't have to hardcore values in code.

I have used Facebook Login dialog with the correct permission and gotten access to a person's business accounts. I received a code after the login process and exchanged it using the /oauth/access_token endpoint to receive a system access token (which does not expire).

I now want to get the business IDs of the businesses that the person using the Facebook Login dialog gave me access to, so that I can link their business to mine using the "on behalf of" approach (I'm the partner, they are the client) .

However, for me to do that I require access to their business ID. How do I get that business ID? I know there is an API which returns all business IDs that I (the partenr) has access to, but I want the one that they just gave me access to using the Facebook Login dialog box. How can I do that?

I am using the WhatsApp Business API to use my chatbot and I needed to connect the Facebook product catalog to the configured WhatsApp number. Does anyone know what I can do to associate a catalog with a WhatsApp account and if it is possible to use the catalog response in the WhatsApp API for consumption? I'm developing a chatbot for restaurants and I wanted the user to be able to place an order through the WhatsApp Business catalog and from there the chatbot would get the rest of the information. I already have a catalog set up and a working WhatsApp number, however, when I associate the menu with the registered phone number, the catalog does not appear on the WhatsApp profile of the registered number.