dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.99k stars 1.14k forks source link

Post a photo ? #864

Closed Araknos closed 5 years ago

Araknos commented 5 years ago

Hello, It's more a question than an issue, sorry for that. I'm writing a program in nodejs that post a photo on my page. It's a pain finding a solution and I'm just discovering ig api. Maybe it's just not possible. I wrote that:

` const pathOrStream = "./avatar.png"; var Client = require('instagram-private-api').Client.V1;

Client.Session.create(device, cookiePath, "user", "pass") .then(session => { return [Client.Upload.photo(session, pathOrStream), session] }) .spread((upload, session) => { return Client.Media.configurePhoto(session, upload.params.uploadId, "you can provide caption or go let it go") }) .then(medium => { console.log(medium) // return Instance of Client.Media });`

Got TypeError: Cannot read property 'V1' of undefined

Is it possible ? How to do that ? Thank you a lot !

Nerixyz commented 5 years ago

It is possible.

  1. You're using an old version. Have you considered updating?
  2. It should be const Client = require('instagram-private-api').V1.Client;
realinstadude commented 5 years ago

Please use the latest library version. Check this examples: https://github.com/dilame/instagram-private-api/blob/master/examples/upload-photo-from-web.example.ts https://github.com/dilame/instagram-private-api/blob/master/examples/upload-photo.example.ts

Araknos commented 5 years ago

Thank's for your quick answers. I got now: UnhandledPromiseRejectionWarning: IgCheckpointError: POST /api/v1/accounts/login/ - 400 Bad Request; challenge_required What's that ?

Nerixyz commented 5 years ago

See: https://github.com/dilame/instagram-private-api/blob/master/examples/checkpoint.example.ts

Araknos commented 5 years ago

Awesome ! Thank's a lot guys !