Open againksy opened 3 years ago
Here is a working example of how to obtain a user's post count:
//requires for instagram
/* tslint:disable:no-console */
var {IgApiClient} = require('instagram-private-api');
var { get } = require('request-promise'); // request is already declared as a dependency of the library
const fs = require('fs');
bot = async () => {
//instagram credentials
const igUsername = "";
const igPassword = "";
//instagram session handling
function saveSession(data) {
fs.writeFileSync('./igSession.dat', JSON.stringify(data));
return data;
}
function checkSession() {
return fs.existsSync('./igSession.dat');
}
function loadSession() {
return JSON.parse(fs.readFileSync('./igSession.dat').toString());
}
const ig = new IgApiClient();
ig.state.generateDevice(igUsername);
ig.request.end$.subscribe(async () => {
const serialized = await ig.state.serialize();
delete serialized.constants; // this deletes the version info, so you'll always use the version provided by the library
saveSession(serialized);
});
if (checkSession()) {
// import state accepts both a string as well as an object
// the string should be a JSON object
await ig.state.deserialize(loadSession());
}
const auth = await ig.account.login(igUsername, igPassword);
const userID = await ig.user.getIdByUsername('google');
const userInfo = await ig.user.info(userID);
console.log(userInfo.media_count);
}
bot();
Can't find in the documentation. Which instance is keeping this info? How to find the all posts for specific user count? Also most links in the repository not wokring.