Posts under category Facebook Graph API

If I make this call to get campaign data from the Graph API:

const url = `https://graph.facebook.com/v19.0/${account}/insights?time_increment=30&time_range={since:'2024-01-01',until:'2024-01-30'}&level=campaign&fields=campaign_id,campaign_name,frequency,spend,reach,impressions,objective,optimization_goal,clicks,actions&action_breakdowns=action_type&access_token=${token}`;  

I get 219,189 as the total reach. However, if I make the same call, changing only time_increment=7

const url = `https://graph.facebook.com/v19.0/${account}/insights?time_increment=7&time_range={since:'2024-01-01',until:'2024-01-30'}&level=campaign&fields=campaign_id,campaign_name,frequency,spend,reach,impressions,objective,optimization_goal,clicks,actions&action_breakdowns=action_type&access_token=${token}`; 

I get 287,141 as the total reach. If, finally, I change time_increment=1

const url = `https://graph.facebook.com/v19.0/${account}/insights?time_increment=1&time_range={since:'2024-01-01',until:'2024-01-30'}&level=campaign&fields=campaign_id,campaign_name,frequency,spend,reach,impressions,objective,optimization_goal,clicks,actions&action_breakdowns=action_type&access_token=${token}`;      

I get 391,900 as total reach. As we can see, these are very inconsistent figures. What could be the cause of this Thanks in advance!

Technical detail: I'm calling the data via the GET REST API method >> const data = await fetch(url). I'm not using an SDK.

I expect to recieve the same reach figure, independently of the time_increment parameter.

I want to create a catalog programmatically, without using commerce manager. I am using this end point but I keep getting this error message": "Unsupported post request. Object with ID does not exist, cannot be loaded due to missing permissionss.. These are my permissions: catalog_management, ads_management, business_management, whatsapp_business_management, commerce_account_read_settings, commerce_account_manage_orders, commerce_account_read_orders, whatsapp_business_messaging and I can see my owned catalogs by using this same business id but cannot create one. Am I missing something here?

Hello everyone,
I'm currently experiencing an issue with the Facebook Graph API when querying the /me/accounts endpoint. Despite having a valid access token and all the necessary scopes, the data array in the response remains empty.
Here’s an overview of the situation:
API Request:
curl -i -X GET \
"https://graph.facebook.com/v20.0/me/accounts?fields=id%2Cname%2Caccess_token&access_token="
Access Token Info:
{
"perms": [
"publish_video",
"pages_manage_cta",
"pages_manage_instant_articles",
"pages_show_list",
"read_page_mailboxes",
"ads_management",
"ads_read",
"business_management",
"pages_messaging",
"pages_messaging_subscriptions",
"instagram_basic",
"instagram_manage_comments",
"instagram_manage_insights",
"instagram_content_publish",
"page_events",
"pages_read_engagement",
"pages_manage_metadata",
"pages_read_user_content",
"pages_manage_ads",
"pages_manage_posts",
"pages_manage_engagement",
"instagram_manage_events",
"manage_app_solution",
"public_profile"
],
"user_id": "",
"app_id":
}
API Response:
{
"data": []
}
I have verified that: - The access token is valid and includes all the necessary scopes (e.g., pages_show_list, pages_manage_metadata, etc.). - The user associated with the access token does indeed manage Facebook Pages. - The app is in live mode and all necessary permissions have been requested and approved. - I've tried debugging using the Graph API Explorer, but the result remains the same: the data array is always empty.
Potential Cause:
I came across this documentation about "Tech Providers" and suspect that it could be related to restrictions placed on tech providers accessing data on behalf of clients. However, it's unclear if these restrictions are causing the empty data response or if something else might be at play.
My Question:
Could these tech provider restrictions be the reason for the empty response?
Is there something specific I need to verify or modify in the app settings related to these restrictions?
Are there any additional steps I should take to ensure access to the pages data through the API?
Any insights or guidance on how to resolve this issue would be greatly appreciated.
Thank you!

I'm creating an automation flow with puppeteer to log in to Facebook and get the User Access Token. The code is a NodeJS code and pretty simple for now:

require("dotenv").config(); const { tagmanager } = require("googleapis/build/src/apis/tagmanager"); const puppeteer = require("puppeteer"); (async () => {   // Lança o navegador com a UI visível para que possamos acompanhar o processo   const browser = await puppeteer.launch({ headless: false });   const page = await browser.newPage();   // Define a URL para o fluxo de login do Facebook   const facebookLoginURL = `https://www.facebook.com/v16.0/dialog/oauth?client_id=${process.env.FB_APP_ID}&redirect_uri=${process.env.FB_REDIRECT_URI}&scope=email,public_profile&response_type=code`;   // Vai para a página de login do Facebook   await page.goto(facebookLoginURL);   // Espera o span com o texto específico "Permitir todos os cookies"   await page.waitForFunction(() => {     const elements = Array.from(document.querySelectorAll("span"));     // Verifica se algum elemento contém o texto "Permitir todos os cookies"     const targetElement = elements.find(       (element) => element.textContent.trim() === "Permitir todos os cookies"     );     // Se o elemento for encontrado, retorna true para sair do loop     if (targetElement) {       return true;     }     // Continua o loop se não encontrar o elemento     return false;   });   // Encontra e clica diretamente com page.click()   await page.evaluate(() => {     const elements = Array.from(document.querySelectorAll("span"));     // Verifica se algum elemento contém o texto "Permitir todos os cookies"     const targetElement = elements.find(       (element) => element.textContent.trim() === "Permitir todos os cookies"     );     if (targetElement) {       targetElement.setAttribute("id", "cookie-button"); // Atribui um ID temporário para garantir o seletor     }   });   await page.click("#cookie-button"); // Usa o seletor id para clicar diretamente   // Espera que o campo de email esteja disponível e preenche com o seu usuário de teste   await page.waitForSelector("#email");   await page.type("#email", process.env.FB_TEST_USER_EMAIL);   // Preenche a senha com a senha do usuário de teste   await page.type("#pass", process.env.FB_TEST_USER_PASSWORD);   // Clica no botão de login   await page.click('button[name="login"]');   // Espera o redirecionamento para a URL de callback   await page.waitForNavigation();   // Obtém a URL atual (que deve conter o código de autenticação)   const redirectedUrl = page.url();   console.log("Redirected URL:", redirectedUrl);   //here we need to handle 2FA   //...   // Extraia o código da URL de redirecionamento   const urlParams = new URLSearchParams(redirectedUrl.split("?")[1]);   const authCode = urlParams.get("code");   console.log(`Auth Code: ${authCode}`);   await browser.close(); })(); 

The puppeter code above comprises the following steps:

  1. Open Facebook login page (OK)

  2. Log in with user and password (OK)

  3. Enter 2FA code (not OK)

  4. Get User Access Token (not OK because of 3)

I'm having trouble with step 3, because I don't know how to get the code automatically, i.e. without having to enter it manually. Any solutions?

2FA is enabled in Meta Business Manager and I normally receive this code by SMS or via the Microsoft Authenticator app. I could perhaps disable 2FA for the user in question in the Meta Business Manager, but that's something I wouldn't want to do, as it reduces credibility on the Meta side, which could block the user.

So I'd like to "hear" from you about possible ways of dealing with this. Thanks in advance!

I want to handle with 2FA by using puppeteer to login on Facebook with a normal user account.