Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. var Promise = require('bluebird');
  2. var Client = require('instagram-private-api').V1;
  3. var device = new Client.Device('someuser');
  4. var storage = new Client.CookieFileStorage('someuser.json');
  5.  
  6. var username = "";
  7. var password = "";
  8. var mailUser = "";
  9. var mailPW = "";
  10.  
  11. var proxyURL = ""
  12.  
  13. function challengeMe(error) {
  14. return Client.Web.Challenge.resolve(error)
  15. .then(function(challenge) {
  16. console.log("Hey There!")
  17. return challenge.email()
  18. })
  19. .then(function(challenge) {
  20. return challenge.code(123456) //The error is here
  21. })
  22. }
  23.  
  24. function loginAndFollow(device, storage, user, password) {
  25. return Client.Session.create(device, storage, user, password)
  26. .then(function(session) {
  27. // Now you have a session, we can follow / unfollow, anything...
  28. // And we want to follow Instagram official profile
  29. return [session, Client.Account.searchForUser(session, 'instagram')]
  30. })
  31. .spread(function(session, account) {
  32. return Client.Relationship.create(session, account.id);
  33. })
  34. };
  35.  
  36. loginAndFollow(device, storage, username, password)
  37. .catch(Client.Exceptions.CheckpointError, function(error){
  38. // Ok now we know that Instagram is asking us to
  39. // prove that we are real users
  40. return challengeMe(error);
  41. })
  42. .then(function(relationship) {
  43. console.log(relationship.params)
  44. // {followedBy: ... , following: ... }
  45. // Yey, you just followed an account
  46. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement