@givemoneybiatch
Немного веб, немного гейм

Как прочитать и сериализовать ответ Instagram?

Пытаюсь получить список подписчиков с помощью instagram-private-api. Сделал все как в примере, берем данные с инстаграма по запросу на NodeJS эндпоинт.

var randomString = 'mydeviceandroid';
var accountId = 'XXX';

var device = new Client.Device(randomString);
var storage = new Client.CookieFileStorage(__dirname + '/cookies/' + randomString + '.json');

router.get('/api/followers', function (request, response) {
    Client.Session.create(device, storage, process.env.USERNAME, process.env.PASSWORD)
        .then(function (session) {
            // Now you have a session, we can follow / unfollow, anything...
            var feed = new Client.Feed.AccountFollowers(session, accountId);
            return feed.get();
        })
        .then(function (data) {
            response.status(200).send({ data: data });
        });
});

В ответ данные приходят, только отправить их на фронт почему то невозможно - вылетает ошибка в консоли NodeJS
Unhandled rejection Error: store does not support getAllCookies and cannot be serialized

Что не так с этим ответом от Инстаграма? Это не обычный json, вот пример ответа с одним подписчиком.

Account {
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined,
  _session:
   Session {
     _device:
      Device {
        username: 'test',
        _md5int: 5456456,
        _api: 21,
        _release: '5.1.1',
        _dpi: '577',
        _resolution: '320x480',
        _info: [Object],
        _language: 'en_US' },
     _cookiesStore:
      CookieFileStorage {
        storage: { idx: { 'i.instagram.com':
   { '/':
      { rur: Cookie="rur=FTW; Path=/; Secure; HttpOnly; hostOnly=true; aAge=425ms; cAge=1543888ms",
        mid: Cookie="mid=xxx; Expires=Fri, 27 Oct 2028 22:59:13 GMT; Max-Age=315360000; Path=/; Secure; hostOnly=true; aAge=750ms; cAge=1543887ms",
        urlgen: Cookie="urlgen="{\"xxx\": xxx}:xxx-64"; Path=/; Secure; HttpOnly; hostOnly=true; aAge=425ms; cAge=1543887ms",
        mcd: Cookie="mcd=3; Expires=Fri, 27 Oct 2028 22:59:13 GMT; Max-Age=315360000; Path=/; Secure; hostOnly=true; aAge=750ms; cAge=1543887ms",
        csrftoken: Cookie="csrftoken=xxx; Expires=Tue, 29 Oct 2019 23:24:56 GMT; Max-Age=31449600; Path=/; Secure; hostOnly=true; aAge=424ms; cAge=1543887ms",
        ds_user: Cookie="ds_user=e.nordic14; Expires=Mon, 28 Jan 2019 22:59:52 GMT; Max-Age=7776000; Path=/; Secure; HttpOnly; hostOnly=true; aAge=750ms; cAge=1504497ms",
        shbid: Cookie="shbid=5375; Expires=Tue, 06 Nov 2018 22:59:52 GMT; Max-Age=604800; Path=/; Secure; HttpOnly; hostOnly=true; aAge=750ms; cAge=1504496ms",
        shbts: Cookie="shbts=xxx; Expires=Tue, 06 Nov 2018 22:59:52 GMT; Max-Age=604800; Path=/; Secure; HttpOnly; hostOnly=true; aAge=750ms; cAge=1504496ms",
        ds_user_id: Cookie="ds_user_id=7968036481; Expires=Mon, 28 Jan 2019 23:24:56 GMT; Max-Age=7776000; Path=/; Secure; hostOnly=true; aAge=425ms; cAge=1504494ms",
        sessionid: Cookie="sessionid=XXX; Expires=Wed, 30 Oct 2019 22:59:52 GMT; Max-Age=31536000; Path=/; Secure; HttpOnly; hostOnly=true; aAge=750ms; cAge=1504493ms",
        is_starred_enabled: Cookie="is_starred_enabled=yes; Expires=Fri, 27 Oct 2028 22:59:55 GMT; Max-Age=315360000; Path=/; Secure; HttpOnly; hostOnly=true; aAge=750ms; cAge=1502059ms",
        igfl: Cookie="igfl=e.nordic14; Expires=Wed, 31 Oct 2018 22:59:55 GMT; Max-Age=86400; Path=/; Secure; HttpOnly; hostOnly=true; aAge=750ms; cAge=1502059ms",
        ig_direct_region_hint: Cookie="ig_direct_region_hint=FRC; Expires=Tue, 06 Nov 2018 22:59:55 GMT; Max-Age=604800; Path=/; Secure; HttpOnly; hostOnly=true; aAge=750ms; cAge=1501300ms" } } } } },
     _jar: RequestJar { _jar: [Object] } },
  _params:
   { pk: xxx,
     username: 'xxx',
     fullName: 'xxx',
     isPrivate: false,
     profilePicUrl: 'XXX',
     profilePicId: 'XXX',
     isVerified: false,
     hasAnonymousProfilePicture: false,
     reelAutoArchive: 'on',
     picture: 'XXX',
     id: XXX},
  id: XXX}
  • Вопрос задан
  • 559 просмотров
Пригласить эксперта
Ответы на вопрос 1
opium
@opium
Просто люблю качественно работать
Отправьте просто строку
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы