-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
50 lines (39 loc) · 1.32 KB
/
example.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
39
40
41
42
43
44
45
const { Client, Authentication, FeedMedia, EVENTS, CROP_SIZES } = require("./index");
require('dotenv').config({
path: './.env'
});
const client = new Client({
authentication: new Authentication({
username: process.env.IG_USERNAME,
password: process.env.IG_PASSWORD,
}),
puppeteerOptions: {
headless: false,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
}
});
for (const event in EVENTS) {
client.on(EVENTS[event], function () {
console.log(`on ${EVENTS[event]}`)
})
}
client.on(EVENTS.AUTHENTICATED, async () => {
// client.getInfo().then(info => console.log(info));
// client.getUser("rifkiiard").then(info => console.log(info));
// client.getUserPicture("rifkiiard").then(url => console.log(url));
client.postFeed({
media: [
FeedMedia.fromUrl({
url: "https://upload.wikimedia.org/wikipedia/id/1/19/Optimus10108pieces.jpg",
cropSize: CROP_SIZES.ORIGINAL
}),
// FeedMedia.fromUrl({
// url: "http://techslides.com/demos/sample-videos/small.mp4",
// cropSize: CROP_SIZES.ORIGINAL
// }),
],
crop: CROP_SIZES.LANDSCAPE,
caption: "I am Optimus Prime ..."
})
})
client.initialize();