-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (25 loc) · 810 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require("dotenv").config();
const { IgApiClient } = require('instagram-private-api');
const { get } = require('request-promise');
let image;
async function getImage() {
const res = await fetch("https://meme-api.com/gimme")
image = await res.json();
url = image.url
console.log(image.url)
}
getImage();
const postToInsta = async () => {
const ig = new IgApiClient();
ig.state.generateDevice(process.env.IG_USERNAME);
await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
const imageBuffer = await get({
url: image.url,
encoding: null,
});
await ig.publish.photo({
file: imageBuffer,
caption: image.title + "\n by " + image.author + " from " + image.postLink,
});
}
postToInsta();