Проблема с подключением к Instagram с использованием Instagram4j в Java - PullRequest
0 голосов
/ 16 марта 2020

Я пытаюсь выполнить вход в систему, на локальном хосте все в порядке, но в службе (AWS) не выполняется вход. У меня есть способ сделать логин и сохранить логин в файле cook ie .txt. Если мне потребуется логин, найдите файл cook ie, чтобы больше не входить в систему

Мой код для сделать логин следующий:

protected Instagram4j login(Instagram4j instagram){
  try {
    instagram.setup();
    instagram.login();

    File cookiesFile = new File(System.getProperty("user.dir") + FILE_COOKIES);
    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cookiesFile));
    oos.writeObject(instagram.getCookieStore());
    oos.close();
  } catch (IOException e){
    e.printStackTrace();
  }

  return instagram;
}

Для проверки куки:

protected Instagram4j checkLogin(Instagram4j instagram){
    Instagram4j instagram2 = null;

    try {
      // Open de cookies in the .txt
      ObjectInputStream ois = new ObjectInputStream(new FileInputStream(System.getProperty("user.dir") + FILE_COOKIES));
      CookieStore cookieStore = (CookieStore) ois.readObject();
      ois.close();

      // Verify the session
      instagram2 = Instagram4j.builder().username(INSTAGRAM_USERNAME)
        .password(INSTAGRAM_PASSWORD)
        .uuid(instagram.getUuid())
        .cookieStore(cookieStore)
        .build();
      instagram2.setup();
    } catch (IOException e) {
      e.getMessage();
    } catch (ClassNotFoundException e) {
      e.getMessage();
    }

    return instagram2;
}

Для вызова метода:

Instagram4j instagramLogin = Instagram4j.builder().username(INSTAGRAM_USERNAME).password(INSTAGRAM_PASSWORD).build(); 
Instagram4j instagram = (checkLogin(instagramLogin) == null) ? login(instagramLogin) : checkLogin(instagramLogin);

Ошибка в подаче :

2020-03-16 12:02:36.640 INFO 18541 --- [task-scheduler-10] o.brunocvcunha.instagram4j.Instagram4j : Setup...

2020-03-16 12:02:36.640 INFO 18541 --- [task-scheduler-10] o.brunocvcunha.instagram4j.Instagram4j : Device ID is: android-547cbdeb2f1634d4, random id: c8c30455-72fd-4a0e-a396-5c5d2e422092

2020-03-16 12:02:36.641 INFO 18541 --- [task-scheduler-10] o.brunocvcunha.instagram4j.Instagram4j : Setup...

2020-03-16 12:02:36.641 INFO 18541 --- [task-scheduler-10] o.brunocvcunha.instagram4j.Instagram4j : Device ID is: android-547cbdeb2f1634d4, random id: fad1e2c1-61e8-4c13-a642-320b402ce74a

2020-03-16 12:02:36.641 INFO 18541 --- [task-scheduler-10] o.brunocvcunha.instagram4j.Instagram4j : Sending request: org.brunocvcunha.instagram4j.requests.InstagramSearchUsernameRequest

**2020-03-16 12:02:36.973 INFO 18541 --- [task-scheduler-10] o.b.i.requests.InstagramRequest : Reading InstagramSearchUsernameResult from {"message": "login_required", "error_title": "You've Been Logged Out", "error_body": "Please log back in.", "logout_reason": 2,**
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...