Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posting image to account via local file #257

Open
mattwillz opened this issue Jun 5, 2021 · 2 comments
Open

Posting image to account via local file #257

mattwillz opened this issue Jun 5, 2021 · 2 comments

Comments

@mattwillz
Copy link

Hey, I was trying to post an image to an account, and it works but only when using a link to an image. Instead, I want to be able to post an image to an account through a local file, but I am unable to do so. I have tried the following code, and also tried using a local server, and then doing something like localhost:8888/image.jpeg, but this didn't work either. I've found one similar question to this, but couldn't find a suitable answer that worked for me, any support is appreciated, here is the code I tried:

const Instagram = require('instagram-web-api');
const { username, password } = require("./config.json");
const client = new Instagram({ username, password });

  const photo = "./image.jpeg";
  
  client.login().then(async() => {
      const { media } = await client.uploadPhoto({ photo: photo, caption: 'testing', post: 'feed' });
      console.log(`https://www.instagram.com/p/${media.code}/`);
  })

Additionally, the error I get when using this code is the following:

(node:78848) UnhandledPromiseRejectionWarning: StatusCodeError: 400 - "{\"debug_info\":{\"retriable\":false,\"type\":\"ProcessingFailedError\",\"message\":\"Request processing failed\"}}"
@MonsieurBibo
Copy link

This post on SO might help you or this issue too.

@pcurz
Copy link

pcurz commented Sep 2, 2021

`const Instagram = require('instagram-web-api');
const fs = require ('fs');
const { username, password } = require("./config.json");
const client = new Instagram({ username, password });

const photo = fs.readFileSync("./image.jpeg");

client.login().then(async() => {
const { media } = await client.uploadPhoto({ photo: photo, caption: 'testing', post: 'feed' });
console.log(https://www.instagram.com/p/${media.code}/);
})`

also, be sure that the image ratio is 1:1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants