L
L
lex2017-04-12 23:25:35
Node.js
lex, 2017-04-12 23:25:35

Instagram private api and public api, how to get a token for a nodejs application and is it also needed in a private api?

Good time of the day!
1. how to build an application with receiving a token from insta? maybe requests with promises? if possible a piece of code.
2. And for publications, etc., I messed up the npm private api module, but it also swears, although the device is created all the rules, maybe someone knows the nuances, I would be very grateful

var Client = require('instagram-private-api').V1;
var device = new Client.Device('someuser');
var storage = new Client.CookieFileStorage(__dirname + './cookies/someuser.json');
 
// And go for login 
Client.Session.create(device, storage, 'someuser', 'somepassword')
    .then(function(session) {
   		// Now you have a session, we can follow / unfollow, anything... 
        // And we want to follow Instagram official profile 
        return [session, Client.Account.searchForUser(session, 'instagram')]   
    })
    .spread(function(session, account) {
        return Client.Relationship.create(session, account.id);
    })
    .then(function(relationship) {
        console.log(relationship.params)
        // {followedBy: ... , following: ... } 
        // Yey, you just followed @instagram 
    })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TheZanki, 2017-12-19
@TheZanki

Here is an example using the instagtam-private-api library

var Client = require('instagram-private-api').V1;
var device = new Client.Device('myuser');
var storage = new Client.CookieFileStorage(__dirname + '/cookies/myuser.json');

var user = 'login'
var pass = 'passwod';


Client.Session.create(device, storage, user, pass).then(session => {});

var session = new Client.Session(device, storage);

Client.Account.searchForUser(session, 'instagram')
  .then(data => {
    console.log(data._params);
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question