Posts under category Facebook Graph API

I’m facing an issue where the Facebook Graph API is not returning lead data for a specific ad, even though the leads are visible in the Ads Manager.

Here’s what I’ve done: I’m using the following endpoint to retrieve the leads: GET /{ad_id}/leads?fields=id,created_time,field_data&limit=1000

The leads for other ads are returned correctly, but for one particular ad ("ad1 - Copy"), no leads are returned, even though I can clearly see them in the Facebook Ads Manager (65 leads in total). I’ve made sure that my access token has the required permissions: leads_retrieval ads_read ads_management pages_manage_ads I’ve also tried adding parameters like date_preset=maximum, but this doesn't help with retrieving the missing leads. I've checked Stack Overflow and the Facebook Developer forums, but I haven't found a solution specific to this issue. Has anyone encountered a similar issue, and is there a known fix or workaround for this discrepancy between the Ads Manager and the API? Any help or guidance would be greatly appreciated!

Environment: API version: v20.0 Access token permissions: leads_retrieval, ads_read, ads_management What I’ve Tried: Refreshing the token and regenerating it with proper permissions. Adding various query parameters (like limit and date_preset). Expected Behavior: The API should return all leads for "ad1 - Copy" just like it does for other ads.

I Am trying to upload Reels from a business Instagram account for that i already have access token and long lived token.The problem is that whenever i try to publish a reel it gives me "The video file you selected is in a format that we don't support." error code:352 and error_subcode:2207026.I have also converted that video but its saying the same.But I am able to upload a video of "640x480" but not any other resolution like 720x1280 etc. The url of video is aws

I have tried converting video using ffmpeg but it gives me aspect ratio error on 720x1280 whether its 9:16 or 16:9 when i try to upload video of like 1080x1920 it gives me streams error i have also added validation in my uploadReel function and funtion return true but still i am getting video format not supported error

import { Request, Response } from 'express'; import axios from 'axios'; import asyncHandler from '../../../middlewares/asyncHandler'; import ffmpeg from 'fluent-ffmpeg'; import ffmpegInstaller from '@ffmpeg-installer/ffmpeg'; ffmpeg.setFfmpegPath(ffmpegInstaller.path); export const uploadReel = asyncHandler(async (req: Request, res: Response) => {   const { longLivedToken, videoUrl }: any = req.body;   if (!longLivedToken || !videoUrl) {     return res.status(400).json({ error: 'Invalid data' });   }   console.log('Checking video format for:', videoUrl);   // Check if the video has supported codecs (H.264 for video and AAC for audio)   ffmpeg(videoUrl).ffprobe((err, metadata) => {     if (err) {       console.error('Error reading video metadata:', err.message);       return res.status(400).json({ error: 'Unable to check video metadata or invalid file.' });     }     console.log('Video metadata:', JSON.stringify(metadata, null, 2));     const hasValidCodec = metadata.streams.some(       (stream: any) => stream.codec_name === 'h264' && stream.codec_type === 'video'     ) && metadata.streams.some(       (stream: any) => stream.codec_name === 'aac' && stream.codec_type === 'audio'     );     if (!hasValidCodec) {       console.error('Unsupported file format. Expected H.264 video codec and AAC audio codec.');       return res.status(400).json({         error: 'Unsupported file format. Ensure the video is in MP4 format with H.264 video codec and AAC audio codec.',       });     }     console.log('Video format is supported. Proceeding with upload.');     // If format is supported, proceed to upload the video     axios.post(       `https://graph.instagram.com/v20.0/me/media`,       {         media_type: 'REELS',         video_url: videoUrl, // Publicly accessible URL of the video file         access_token: longLivedToken,       },       {         headers: { 'Content-Type': 'application/json' },       }     )       .then((response) => {         console.log('Reel successfully uploaded:', response.data);         return res.status(200).json({ mediaId: response.data.id });       })       .catch((error) => {         console.error('Error uploading reel:', error.response ? error.response.data : error.message);         return res.status(500).json({ error: 'Failed to upload reel' });       });   }); }); export const publishReel = asyncHandler(async (req: Request, res: Response) => {   const { mediaId, longLivedToken }: any = req.body;   if (!mediaId || !longLivedToken) {     return res.status(400).json({ error: 'Invalid data' });   }   try {     const response = await axios.post(       `https://graph.instagram.com/v20.0/me/media_publish`,       {         creation_id: mediaId,         access_token: longLivedToken,       },       {         headers: { 'Content-Type': 'application/json' }       }     );     return res.status(200).json({ postId: response.data.id }); // Return post ID   } catch (error) {     console.error('Error publishing image:', error.response ? error.response.data : error.message)}      }); 

enter image description here`

Hello! I'm trying to override the default link thumbnail in my post, but for this particular one, the request succeeds but the thumb shows up blank on site.
Here is the POST request body for the request I'm making to /{page-id}/feed, as per the Custom Link Page Post Image section in https://developers.facebook.com/docs/graph-api/reference/v20.0/page/feed#publish
{
"link": "https://www.huffpost.com/entry/weirdest-thing-seen-at-airport_l_66b3add9e4b05d0bc2808225",
"name": "People Are Revealing The Weirdest Things They've Ever Seen At The Airport",
"message": "What is it about the airport that brings out the bizarre in people?",
"picture": "https://img.buzzfeed.com/pubhub-api-prod-us-east-1/assets/6cff236dbba745b2893760bc74d7b64f/test.png",
"description": "What is it about the airport that brings out the bizarre in people?",
"is_published": true
}
Is there something about this particular image/post that would cause the thumb to show up blank like this?

I implemented successfully the code to make a request to the Facebook GraphRequest by using the the following code:

GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {   ... } 

In some documentation I found the code below to retrieve values:

Bundle parameters = new Bundle(); parameters.putString("fields","name,email"); request.setParameters(parameters); request.executeAsync(); 

I want to use System.out.println() to print out name and email of the person who logged in successfully with Facebook to my Android app. How can I invoke request to print out those values? Thank you.

UPDATE 1:

I suspect I might be experiencing the same problem reported at Facebook Integration Android: onCompleted(GraphJSONObjectCallback) block not executing: onCompleted(GraphJSONObjectCallback) block not executing

See more context of my code:

private void handleFacebookAccessToken(LoginResult loginResult) {   GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {     @Override     public void onCompleted(@Nullable JSONObject jsonObject, @Nullable GraphResponse graphResponse) {       //Access the response here and retrieve the information you want and print it out       String rawResponse = graphResponse.getRawResponse();       System.out.println("rawResponse: "+rawResponse);     });     Bundle parameters = new Bundle();     parameters.putString("fields","name,email");     request.setParameters(parameters);     request.executeAsync(); } 

I was expecting the following line to print out the response to the request, but I do not see anything printed out:

System.out.println("rawResponse: "+rawResponse); 

I've tried getting
graph.facebook.com/v20.0/1*************3_7*************1/comments, where
1*************3 is a valid user id, and
7*************1 is a valid (and public) post id.

Unfortunately, the Graph API Explorer shows an OAuthException:

{   "error": {     "message": "Unsupported get request. Object with ID '1*************3_7*************1' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",     "type": "GraphMethodException",     "code": 100,     "error_subcode": 33,     "fbtrace_id": "A*********************Z"   } } 

How could I get all the comments of a user's public Facebook post?

I'd prefer a Graph API (or other official Meta tool) solution.

But I'm open to other approaches too.