Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Promise = require('bluebird');
- var Client = require('instagram-private-api').V1;
- var device = new Client.Device('someuser');
- var storage = new Client.CookieFileStorage('someuser.json');
- var username = "";
- var password = "";
- var mailUser = "";
- var mailPW = "";
- var proxyURL = ""
- function challengeMe(error) {
- return Client.Web.Challenge.resolve(error)
- .then(function(challenge) {
- console.log("Hey There!")
- return challenge.email()
- })
- .then(function(challenge) {
- return challenge.code(123456) //The error is here
- })
- }
- function loginAndFollow(device, storage, user, password) {
- return Client.Session.create(device, storage, user, password)
- .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);
- })
- };
- loginAndFollow(device, storage, username, password)
- .catch(Client.Exceptions.CheckpointError, function(error){
- // Ok now we know that Instagram is asking us to
- // prove that we are real users
- return challengeMe(error);
- })
- .then(function(relationship) {
- console.log(relationship.params)
- // {followedBy: ... , following: ... }
- // Yey, you just followed an account
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement