Posts under category facebook-graph-api

I'm developing an app that will make use of the Business On Behalf Of API (https://developers.facebook.com/docs/marketing-api/business-manager/guides/on-behalf-of#bm-client). Based on the steps in the documentation above, I was able to progress with regards to login (step 0), creation of the partnership between the BMs (step 1), generation of the access token for the client's BM system user (step 2) and I am stuck in obtaining the system user identification number (step 3) through the following request:

curl -i -X GET
"https://graph.facebook.com/v19.0/me?access_token=<CLIENT_BM_SU_ACCESS_TOKEN>"

I have a valid system user token, with all desired permissions and attributes, validated through the Access Token Debugger (https://developers.facebook.com/tools/debug/accesstoken/?access_token=...&version=v19. 0). However, the request to get this user's id continues to return an empty json as a response.

Request made: curl --location 'https://graph.facebook.com/v19.0/me?fields=id&access_token=...'.

The response is always {} (empty json).

access token debugger output

My app's permissions at login are: pages_read_engagement business_management ads_management

The system user access token created in the customer's BM has the following permissions: ads_management pages_read_engagement

as the documentation suggests (I've already tested generating this token with other permissions, but the problem persists).

I tried to research whether it was a lack of permissions, but I couldn't find anything conclusive. I researched the app's settings and didn't get promising results either. I tested using both Login and Login for Business as a Product for my app, but there was no difference in relation to the problem. Making this same request with user or system user tokens, administrators or not, from my accounts and my BM works as expected (returns the user id), but when it is a system user of the client's BM, following the step the step of the Business Intermediation documentation, it doesn't work.

I need this id to assign the assets to this user and then have access to the client's pages. By manually obtaining the user ID through the debugger and following the other steps, it is possible to complete the entire process and carry out the intermediation as expected (manage the assets on behalf of another company). However, this step is not allowing me to automate the process 100% and will hinder the usability of my application. Am I missing something?

There are several that are similar, none of them relate to this specific problem. I am trying to get FB pages owned by a user. Before this i was getting issue that business pages were not listing so i found that i need to add business_management permission and the permission fixed the issue. But now i am still not getting some user's (previously connected and also sometimes new users) pages and not able to connect with my app. What can be the reason as i have also tried remove app from business integration setting.

But... when I visit the page on the web, I am an admin. I have full access to all the admin functions. It also appears in my list of pages in the Pages Manager app on Android.

I have read the documentation for the hint as to what I am doing wrong, and nothing found helpful.

i have tried it with another app (similar to my requirement) and the page is listing. I'm not able to find what i am missing in my request (may be any permission).

i am trying to upload a reel (MP4, 16 seconds, and 9 MB) using facebook graph API, but i get the following error:

Failed to upload reel: {'error': {'message': 'The video file you tried to upload is too small. Please try again with a larger file.', 'type': 'OAuthException', 'code': 382, 'error_subcode': 1363022, 'is_transient': False, 'error_user_title': 'Video Too Small', 'error_user_msg': 'The video you tried to upload is too small. The minimum size for a video is 1 KB. Please try again with a larger file.', 'fbtrace_id': 'A0WVVSGWnXEfffdwrjFUENsJVC'}}

The code:

import requests from datetime import datetime import subprocess import os def human_readable_to_timestamp(date_string):     try:         # Convert the human-readable date string to a datetime object         dt_object = datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S')         # Convert the datetime object to UNIX timestamp         timestamp = int(dt_object.timestamp())         return timestamp     except ValueError:         print("Invalid date format. Please provide the date in the format: YYYY-MM-DD HH:MM:SS")         return None def extract_frame(video_path, time, output_path):     # Use ffmpeg to extract a frame from the video at the specified time     cmd = [         'ffmpeg', '-y',         '-i', video_path,         '-ss', str(time),         '-vframes', '1',         '-q:v', '2',  # Set quality (1-31, 1 being highest)         output_path     ]     subprocess.run(cmd, check=True) def upload_reel_with_thumbnail(video_path, thumbnail_path, access_token, file_size, target_file_size, scheduled_publish_time=None):          # Endpoint for uploading videos     url = 'https://graph.facebook.com/v15.0/me/videos'     if file_size < target_file_size:         # Pad the file with zeros to reach the target file size         with open(video_path, 'ab') as video_file:             video_file.write(b'\0' * (target_file_size - file_size))             file_size = target_file_size  # Update the file size after padding     print (file_size)     # Video data     video_data = {         'access_token': access_token,         #'file_url': video_path,         'description': 'Check out this amazing reel!',         'file_size': file_size,         'published': 'false'         # Additional parameters can be added here as needed     }     # If scheduling time is provided, add it to the request     if scheduled_publish_time:         video_data['scheduled_publish_time'] = human_readable_to_timestamp(scheduled_publish_time)     try:         # Sending POST request to upload the video         files = {'file': video_path}         response = requests.post(url, data=video_data, files=files)         response_json = response.json()         # Check if the upload was successful         if 'id' in response_json:             reel_id = response_json['id']             print("Reel uploaded successfully! Reel ID:", reel_id)             # Upload the thumbnail             upload_thumbnail(reel_id, thumbnail_path, access_token)             # If scheduling time is provided, schedule the reel             if scheduled_publish_time:                 schedule_reel(reel_id, scheduled_publish_time, access_token)         else:             print("Failed to upload reel:", response_json)     except Exception as e:         print("An error occurred:", str(e)) def upload_thumbnail(reel_id, thumbnail_path, access_token):     # Endpoint for uploading thumbnail     url = f'https://graph.facebook.com/v15.0/{reel_id}'          # Thumbnail data     files = {'thumb': open(thumbnail_path, 'rb')}     params = {'access_token': access_token}     try:         # Sending POST request to upload the thumbnail         response = requests.post(url, files=files, params=params)         response_json = response.json()         # Check if the thumbnail upload was successful         if 'success' in response_json and response_json['success']:             print("Thumbnail uploaded successfully!")         else:             print("Failed to upload thumbnail:", response_json)     except Exception as e:         print("An error occurred:", str(e)) def schedule_reel(reel_id, scheduled_publish_time, access_token):     # Endpoint for scheduling the reel     url = f'https://graph.facebook.com/v15.0/{reel_id}'     # Schedule data     data = {         'access_token': access_token,         'published': 'false',         'scheduled_publish_time': scheduled_publish_time     }     try:         # Sending POST request to schedule the reel         response = requests.post(url, data=data)         response_json = response.json()         # Check if scheduling was successful         if 'id' in response_json:             print("Reel scheduled successfully!")         else:             print("Failed to schedule reel:", response_json)     except Exception as e:         print("An error occurred:", str(e)) # Example usage if __name__ == "__main__":     # Path to the video file     video_path = '55.mp4'                  file_size = os.path.getsize(video_path)     target_file_size = 10 * 1024  # 30 KB     print (file_size)     # Path to the thumbnail image     thumbnail_path = 'thumbnails/55.jpg'          extract_frame(video_path, 6, thumbnail_path)     # Facebook Access Token     access_token = 'xxxxx'     # Scheduled publish time (human-readable format)     scheduled_publish_time = '2024-04-10 15:30:00'  # Example: April 10, 2024, 15:30:00 UTC     # Call the function to upload the reel with the extracted thumbnail and schedule it     upload_reel_with_thumbnail(video_path, thumbnail_path, access_token, file_size, target_file_size, scheduled_publish_time)          print ("done") 

Any idea :(?

i test like facebook post request in graph facebook api. i use my access token and i have a post_id, this endpoint is:"http://graph.facebook.com/{post_id}/likes". when i send this request then post have a post_id was liked. I did the same thing on postman (endpoint:https://graph.facebook.com/v19.0/{post_id}/likes) and passed in the parameter Authorization:{access_token} but it failed and returned 400 bad request: "error": { "message": "(#3) Publishing likes through the API is only available for page access tokens", "type": "OAuthException", "code": 3, "fbtrace_id": "AU3wMLbb67rRXR4mgF-4FoX" }

I hope that there is someone who has been like me and has solved this problem to share with me the documents to solve it.