instagram-web-api
instagram-web-api copied to clipboard
Tracking new posts with this library
Hello there!
I'm trying to make instagram bot that will track new posts from the public instagram account, then i want to send the link of the post the discord... So i will need to get update from instagram account once it posts new post.. then i need get shortcode of new IG post from it, so I can excute discord code.
So far i made this... i'm able to get data from certain instagram, but how i can search for only new post made? Do some code with cron maybe? Any help will be much appreciate.
I will receive arrays from the last posts and it also contains the shortcode.
const dotenv = require('dotenv');
dotenv.config({ path: './process.env' });
const username = process.env.IGUSERNAME
const password = process.env.IGPASSWORD
const IGclient = new Instagram({ username, password })
IGclient
.login()
.then((data1) => {
console.log('Data1: ', data1)
IGclient
.getProfile()
.then(data => {
console.log("Data: ", data);
(async () => {
await IGclient.login()
await IGclient.getUserByUsername({ username: "worldstar" })
.then(res => console.log('My media:',res.edge_owner_to_timeline_media.edges)) // it returns an array of your user's medias.
})()
})
})