Posts tagged with instagram-api

i wish to find a solution to this issue i have been facing for a long while, trying to publish a reel on instagram. It keeps returning this error: Media upload has failed with error code 2207026 which means its not in the required format, i have tried with countless videos, uploaded them to my google drive and input the link to the video but still the same error, i came across this: Facebook Graph API - Getting error 2207026 when trying to upload video

And also implemented the last suggesstion in my code as shown below:

public String uploadFile(MultipartFile file) {         String extension = StringUtils.getFilenameExtension(file.getOriginalFilename());         var key = UUID.randomUUID() + "." + extension;         String directory = this.fileStorageLocation;         Path newPath = Paths.get(directory).toAbsolutePath().normalize();         try {             Files.createDirectories(newPath);             Path inputFilePath = newPath.resolve(StringUtils.cleanPath(key));             Path outputFilePath = newPath.resolve("output.mp4");             Files.copy(file.getInputStream(), inputFilePath, StandardCopyOption.REPLACE_EXISTING);             executeFFmpegCommand(inputFilePath.toString(), outputFilePath.toString());         } catch (IOException ex) {             Logger.getLogger(FileService.class.getName()).log(Level.SEVERE, null, ex);         }         return key;     }     private void executeFFmpegCommand(String inputFilePath, String outputFilePath) throws IOException {         String ffmpegPath = "C:\\ffmpeg\\bin\\ffmpeg.exe";         String[] ffmpegCommand = {                 ffmpegPath,                 "-i", inputFilePath,                 "-c:v", "libx264",                 "-aspect", "16:9",                 "-crf", "18",                 "-vf", "scale=iw*min(1280/iw\\,720/ih):ih*min(1280/iw\\,720/ih),pad=1280:720:(1280-iw)/2:(720-ih)/2",                 "-fpsmax", "60",                 "-preset", "ultrafast",                 "-c:a", "aac",                 "-b:a", "128k",                 "-ac", "1",                 "-pix_fmt", "yuv420p",                 "-movflags", "+faststart",                 "-t", "59",                 "-y", outputFilePath         };         ProcessBuilder processBuilder = new ProcessBuilder(ffmpegCommand);         processBuilder.inheritIO();         Process process = processBuilder.start();         try {             process.waitFor();             System.out.println("FFmpeg command executed successfully.");         } catch (InterruptedException e) {             throw new IOException("Error executing FFmpeg command: " + e.getMessage(), e);         }     } 

And uploaded the video to my drive and put in the link again, but still the same error, i dont know could be the issue, could someone provide a suggestion or a link to a video that has been tested with, because i dont see what am doing wrong, thanks.

I'm encountering an issue with retrieving Instagram posts using the Facebook Graph API. When I use recent timestamps within a month, the following code works fine:

graph.facebook.com/v19.0/{instagram_business_account}?fields=business_discovery.username({ig_user_id}){media.since(1704477217).until(1714477219){timestamp,caption}}&access_token={access_token}

However, when I attempt to use older timestamps, even though the time interval (difference between since and until) remains the same, the request doesn't return the expected results.

For instance:

graph.facebook.com/v19.0/{instagram_business_account}?fields=business_discovery.username({ig_user_id}){media.since(1672834201).until(1672835201){timestamp,caption}}&access_token={access_token}

Despite being certain that there's a specific post at that interval of time, the API doesn't seem to return it.

I am using Meta graph api https://developers.facebook.com/docs/instagram-api/guides/content-publishing/#reels-posts

and it is working fine for publishing reels immediately.

I don't see in the documentation of any mention of how to schedule the reel at a particular time. (In contrast, you can do this for facebook reels by using scheduled_publish_time

I read online that this should be possible for Instagram as well https://business.instagram.com/blog/instagram-api-features-updates

Question Can you guide me with one example of how to schedule Instagram reel via API ?

Two more optional ones

  1. (Optional) Can I upload video from my local to instagram ? In the docs they require video_url, but for facebook api I can also upload data from local file
  2. (Optional) Is it possible to cross-post in instagram-facebook, same way we can do via Meta Business Suite

Thanks in advance

My goal is: I want to schedule a Reel on Instagram and Facebook at a given time (cross-post at same time) via API. Accounts are connected to each other.

If I use the business suite UI I can schedule into both and I see them marked as "cross post"

I want to do the same thing via API.

What I tried

  1. I can publish instagram reel fine using this api https://developers.facebook.com/docs/instagram-api/guides/content-publishing/#reels-posts BUT I see no way of scheduling there
  2. I can schedule or publish Facebook Reel totally fine via the FB GRaph api BUT can't cross-post to instagram at the same time

I can't find any information for the "share to connected" facebook functionality, or cross-posting scheduling the reel at once in both instagram&facebok.

If I schedule Facebook "Reel/Post" via API is not cross-posted. (see below)

I also can't find any way to schedule Instagram Reel via api

NOTE:

I have already connected my instagram and facebook page and can access both as 1 via business suite.

Questions:

  1. How to cross-schedule reel in both instagram and facebook ? To have same functionality as the ui
  2. If point 1 is not possible, at least how to schedule instagram reel so it is posted automatically at a certain date ? I don't see any documented field in the api for this. I read this https://business.instagram.com/blog/instagram-api-features-updates but no information how to schedule a "reel post" at a given time

Thanks in advance

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!