Posts under category facebook-graph-api

I'm using official Facebbok API for getting ads with /ads_archive endpoint.

Example request:

curl -G \ -d "search_terms='oil'" \ -d "ad_reached_countries=['US']" \ -d "fields=id,ad_creation_time,ad_creative_bodies,ad_creative_link_captions,ad_creative_link_descriptions,ad_creative_link_titles,ad_delivery_start_time,ad_delivery_stop_time,ad_snapshot_url,age_country_gender_reach_breakdown,beneficiary_payers,bylines,currency,delivery_by_region,demographic_distribution,estimated_audience_size,eu_total_reach,impressions,languages,page_id,page_name,publisher_platforms,spend,target_ages,target_gender,target_locations" \ -d "access_token={ACCESS_TOKEN}" \ "https://graph.facebook.com/v19.0/ads_archive" 

Response does include Facebook Page ID. It also includes publisher_platforms field containing Instagram or/and Facebook. But no Instagram ID or username.

I find it weird, because web version of Ad Library (running under private API) shows that data. Example link

How can I get Instagram username using Official Ad Library API?

I've already passed all fields from Archived Ad Schema to my request.

Scraping private API seems hard, because it seems sensitive to proxies.

I am trying to send messages using Graph API where I have certain permissions

email, pages_show_list, business_management, pages_messaging, pages_messaging_subscriptions, instagram_basic, instagram_manage_comments,instagram_manage_insights, instagram_content_publish,, instagram_manage_messages, pages_read_engagement, pages_manage_metadata, pages_read_user_content

Now the wierd part is I have two Roles(Admin both of them, both of them has a Facebook page and connected business instagram account) in the app, Now for one user I am able to send message while in other i get a 403 error

error Data: {   error: {     message: '(#200) Please check if access token has enough IG permissions granular scopes for IG to send API, or if IGSID is valid.',     type: 'OAuthException',     code: 200,     error_subcode: 2534067,     fbtrace_id: 'AouX27HuHoQBu65bb6rBUal'   } } Error Status: 403 Error Headers: AxiosHeaders {   vary: 'Origin',   'access-control-allow-origin': '*',   'cross-origin-resource-policy': 'cross-origin',   'x-app-usage': '{"call_count":5,"total_cputime":0,"total_time":3}',   'content-type': 'application/json',   'www-authenticate': 'OAuth "Facebook Platform" "insufficient_scope" "(#200) Please check if access token has enough IG permissions granular scopes for IG to send API, or if IGSID is valid."',   'facebook-api-version': 'v19.0',   'strict-transport-security': 'max-age=15552000; preload',   pragma: 'no-cache',   'cache-control': 'no-store',   expires: 'Sat, 01 Jan 2000 00:00:00 GMT',   'x-fb-request-id': 'AouX27HuHoQBu65bb6rBUal',   'x-fb-trace-id': 'ERIKbq1Rjf7',   'x-fb-rev': '1012935256',   'x-fb-debug': 'mVMrRrBF3H+nrrHR45BNeWtyqALnup35FrQb9RD8JNQCpmH3n8NhTPYqWVns6Snt1oY6x7RCHIvGzO1cJLP9UQ==',   date: 'Sat, 20 Apr 2024 18:38:20 GMT',   'proxy-status': 'http_request_error;   ......... <some other headers> 'x-fb-connection-quality': 'EXCELLENT; q=0.9, rtt=5, rtx=0, c=10, mss=1380, tbw=372, tp=-1, tpl=-1, uplat=514, ullat=0',   'alt-svc': 'h3=":443"; ma=86400',   connection: 'close',   'content-length': '241' } 

Can anyone please tell me what is going wrong. I tried to create another app, and didn't add user1(for which messages were working) added only user2 and tried sending messages, it was not working. But as soon as I added user1 to this new app, again i was able to send message through this User1's page access token.

Expecting it to work. but it didn't

I'm working on an api that receives notifications from the meta weebhook every time my page have changes. Currently its in test mode, I just want to test the webhook first. In the process I'm able to verify my callback link but once I want to test one of the fields nothing its send to my server. Feed field that I want to test I have a POST controller in my backend that should take care of the request and its working; How do I know that ? Because one of the only fields that sends a request it send_cart field. Send cart field There is one or two more fields that actually send a request, but 98% of them don't work. Im not sure if there an error on the Meta Graph API or I did something wrong. If anyone had this problem, or has an idea how I could solve it, it would be very helpful; because this should have been a simple project but it's taking me a week, and I'm already embarrassed. If more information its needed I'm gonna be responding all the requests. Thanks ! Below its the server code that I'm working with:

  • This is the controller:
exports.facebookWebhook = (req, res) => {   if(req.query["hub.verify_token"] === "my_token"){     res.status(200).send(req.query["hub.challenge"])   }else{     res.status(400).send({ message: "bad request" })   } } exports.facebookWebhookChanges = (req, res) => {   if (!req.body || Object.keys(req.body).length === 0) {     console.log('Received an empty request body');     res.status(400).send('Bad Request: Request body is empty');     return;   }   console.log(req.body)   res.status(200).send({ message: "Ok" }) } 
  • This is the route:
  app.get("/api/facebook/webhook/", controller.facebookWebhook);   app.post("/api/facebook/webhook/", controller.facebookWebhookChanges); 

I already read all the documentation to make sure Im doing everything good, I have read other people posts that doesnt match with my problem. I asked on facebook developer forum to.

I'm encountering an issue with Facebook's Graph API where it inconsistently scrapes Open Graph (OG) meta tags between different language versions of my website, which is built using Next.js version 14 with an architecture using page router. Specifically, the French version of my URLs (manage by a context) consistently returns all expected OG meta data (title, description, image), whereas the regular English version sometimes only returns minimal data (type, updated_time), missing critical tags like title, description, and image.

Here are the key details:

Platform: Next.js version 14 with dynamic content rendering based on user language preferences, which is managed by a context.

Behavior: When using Facebook's Graph API Explorer or the Sharing Debugger, the French URL (e.g., https://wiseduckdev.vercel.app/fr/gpts/framework) always successfully returns full meta tag information. However, the equivalent English URL (e.g., https://wiseduckdev.vercel.app/gpts/framework) often only returns partial data.

Meta Tags: Both versions use identical setups for Open Graph meta tags, confirmed via direct source inspection and tools like SEO Meta in 1 Click.

 <meta property="og:type" content="website" />           <meta property="og:title" content={pageData.category.og_title} />           <meta             property="og:description"             content={pageData.category.og_description}           />           <meta             property="og:url"             content={               activeLanguage === "FR"                 ? `https://${siteUrl}/fr/gpts/${pageData.category.category}`                 : `https://${siteUrl}/gpts/${pageData.category.category}`             }           />           <meta             property="og:image"             content={`https://${siteUrl}${pageData.category.og_image}`}           />           <meta             property="og:locale"             content={translation.og_locale[activeLanguage]}           /> 

Caching: I've purged both server and Facebook caches and forced re-scraping using Facebook's tools, which sometimes resolves the issue temporarily for English URLs but doesn't provide a consistent fix.

I'm looking for insights or suggestions on why this discrepancy might be occurring and how to ensure consistent meta tag scraping by Facebook across all language versions of my site.

Actions Taken to Resolve the Issue:

  • Meta Tag Verification: Confirmed that both the English and French versions of the site have correctly implemented Open Graph (OG) meta tags (og:title, og:description, og:image) using direct source inspection and SEO Meta in 1 Click.
  • Caching Management: Purged server and Facebook caches to ensure fresh data is being fetched and used the Facebook Sharing Debugger to force re-scraping of the URLs.
  • Server Response Checks: Used curl to simulate Facebook’s scraper requests, verifying that the server sends the correct metadata and appropriate HTTP responses.
  • Dynamic Content Handling: Ensured that metadata is dynamically generated based on user language settings and is properly rendered server-side in both language versions.
  • API Utilization: Utilized Facebook’s Graph API Explorer to manually fetch data for both language versions to check the responses and confirm that the issue persists despite correct setup.

Expectations and Goals:

  • Consistent Meta Tag Scraping: Ensure that Facebook’s scraper consistently retrieves all relevant OG meta tags across all language versions of the site, not just the French version.
  • Understanding Root Cause: Gain insights into why the English version sometimes only returns minimal data (type, updated_time) despite identical setups.
  • Reliable Resolution: Find a reliable solution or workaround that ensures all versions of the site are equally optimized for social media sharing, without needing to manually trigger re-scrapes.

I am trying to get a long-lived access token from the Instagram graph API through a python script. No matter what I do, I keep receiving the following error:

{"error":{"message":"Missing client_id parameter.","type":"OAuthException","code":101,"fbtrace_id":"AogeGpzZGW9AwqCYKHlmKM"}} 

My script is the following:

import requests refresh_token_url = 'https://graph.facebook.com/v19.0/oauth/access_token' payload = {     'grant_type': 'fb_exchange_token',      'client_id': '1234567890123456'     'client_secret': '1234abcd1234abcd1234abcd',         'fb_exchange_token':'abcd1234' } r = requests.get(refresh_token_url, data=payload) 

I am for sure passing the client_id parameter. I verified also by printing r.request.body

On the contrary, the request is successful if I send it with the Postman app:

Why do I keep getting that error message? Thank you!