Posts tagged with facebook-graph-api

I am trying to use Facebook Graph API Explorer to get a page access token to a specific page.

But upon selecting the page I need, I am redirected to this new chrome tab:

And after clicking "Done", I don't see this page inside the "Get Token" tab

while finding solution, I read here https://developers.facebook.com/docs/facebook-login/guides/access-tokens/ that to obtain a page access token, I need to start obtaining a user access token

So here is what I did,I clicked "Get user access token"

I did the same thing, I authorized everything and clicked "Done" but the page is still not in the "Get Token" Tab.

I own and created this pages and I have connected it to my business portfolio in https://business.facebook.com/ using the same business I am using with the meta developer app but for some reason it's not appearing in Facebook Graph API Explorer. Please help me get access this pages in graph API Explorer. Thank you

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 trying to send an audio message using the Whatsapp Cloud-api, but I am now dealing with a problem that seems to have no documentation available.

Overview of the issue

  • I send an audio file (mp3) to whatsapp as described here.
  • I verify that the file was sent correctly by downloading the file using the media download endpoint.
  • I then try to send the audio as a message using the endpoint specified here.
  • I receive a webhook request with information about my message, this request informs me that the message failed because of "Media file scrutiny for the file failed with mediaEngineStatus: 0" with the code "131053".

Different things I tried

I tried searching the error code in the documentation, it can be found in this page, the page recommends me to verify the type of the audio files I'm using so I used the file --mime-type command in linux an confirmed that the mp3 is actually an mp3.


I tried using the .ogg format instead of mp3 since audio's on whatsapp by default are of type .ogg. The way I did that was that I sent an audio to myself, download the audio, and tried using it instead. The webhook returned the same thing. I also verified the type of the .ogg file using file --mime-type


I tried sending a hello world template message to myself first, responding that message, and then sending the audio, I tried this step since in the whatsapp documentation it is explained that audio messages can only be sent after someone answers the template message. The webhook still returned the same thing.


I stopped using my own code to do this and started using the Insomnia rest client to do the requests to the whatsapp API to make sure that my code was not a factor in this error, I then repeated all the tests explained above using only the Insomnia, I still had my code receive the webhook results since Insomnia is not capable of doing that, but the results were still the same.


I then decided to use ffmpeg to convert my .mp3 to .mp3 and my .ogg to .ogg in an attempt at guaranteeing the type of the files I was sending despite the action seeming to be redundant. I then repeated all tests using both my code and Insomnia but there was no luck and the results were still the same.

A few key points that I already checked

  • I am using multipart/mime both in Insomnia and my code to send the file and the part about uploading the file works well in both situations
  • The audio does not get corrupted after being sent to the whatsapp API since it can be dowloaded and i can listen to it after.

Why no code in the question

I decided to not add any of my code in this question because I only want an explanation on why this is happening on Insomnia, since it is a standard rest client and it should work as far as I can tell, after I manage to make it work in insomnia I will make the requests work in the same way using my code. This seems to me to be an easier task then trying to change the way my code is doing it from the start.

Bellow I have the requests i sent using insomnia (with private info removed for the print screen)

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.

Using the below end point my page token returns posts from the page:

https://graph.facebook.com/v18.0/{PAGEID}/feed?fields=id,created_time,message,status_type,from,place,picture,attachments&limit=100&access_token={TOKEN}

If I then take the post id from this return and try and get comments for it using the following end point I am getting (#200) Missing Permissions. https://graph.facebook.com/v18.0/{POSTID}/comments?limit=100&fields=created_time,from,comment_count,message,attachment&access_token={TOKEN}&order=chronological

But I am not being told what permissions are missing, and why I cannot get comments. This is also not always the case, this exact scenario works in many other cases, so there is an issue somewhere with the access of the user/page, rather than my process..... But I have no idea what, or how to find out.

If I look at the permission in the access token using the token access debugger tool, we have the following: pages_show_list, business_management, pages_read_engagement, pages_read_user_content, pages_manage_posts, public_profile

and my understanding from reading the documentation is that I just need this one: pages_read_user_content to read comments.

I am so confused.

Any help or suggestions of things I can try would be greatly appreciated. if only the error was more useful, and told me what I was missing, I could have a better idea of how to fix.

Thanks in advance