Instagram-private-api: Unhandled rejection OnlyRankedItemsError: Tag has only ranked items to show, due to blocked content

Created on 14 Jan 2017  ·  8Comments  ·  Source: dilame/instagram-private-api

I'm trying to use Feed.TaggedMedia(session, 'yocale') but for some hashtags I'm getting Unhandled rejection OnlyRankedItemsError: Tag has only ranked items to show, due to blocked content

Here is my code:

app.get('/insta', function (req, res) {

    // And go for login
    Client.Session.create(device, storage, 'username', 'password')
      .then(function (session) {
        feed = new Client.Feed.TaggedMedia(session, 'yocale');
        Promise.map(_.range(0, 20), function () {
          return feed.get();
        }).then(function (results) {
          var media = _.flatten(results);

          var urls = [];
          media.forEach(function (element) {
            urls.push(element._params.images[2].url);
          });
          res.json(urls);
        })
      })
  });

Somebody can help me with that?

Thank you.

Most helpful comment

This exception is also thrown when the tag has so few posts that all items are returned in the first query. client/v1/feeds/tagged-media.js#L33 should be changed to:

if (!that.moreAvailable && !_.isEmpty(data.ranked_items) && _.isEmpty(data.items) && !that.getCursor())

Same goes for location-media.js

All 8 comments

this is happening only if ranked (most liked) post are available under hashtag. For example if instagram will detect some porn or nudity they will only show ranked and newest post stay hidden

expected behavior

Yep. I understood. But how can I get the photos for that hashtag instead of an "error message" as I can do when there's no blocked content. I want to get all photos that Instagram allows me to get.

Thank you : )

@guilhermefalcao pick another hashtag and should work

This exception is also thrown when the tag has so few posts that all items are returned in the first query. client/v1/feeds/tagged-media.js#L33 should be changed to:

if (!that.moreAvailable && !_.isEmpty(data.ranked_items) && _.isEmpty(data.items) && !that.getCursor())

Same goes for location-media.js

@huttarichard And what's the reason of not returning ranked items?

@huttarichard is there a reason ranked_items is not being returned?

How about

// client/v1/exceptions.js
... // line 146
function OnlyRankedItemsError(rankedItems) {
    this.name = "OnlyRankedItemsError";
    this.message = "Tag has only ranked items to show, due to blocked content";
    this.rankedItems = rankedItems;
}
...
// client/v1/feeds/tagged-media.js
... // line 34
throw new Exceptions.OnlyRankedItemsError(data.ranked_items);
...

Line numbers based off of commit 9d0691a6258519017c7b3fcd11286b4cf24c1ecb

Note, data.ranked_items is not adapted to Media model.

Sample object from data.ranked_items

{
    "taken_at": 15***********3,
    "pk": "181********************68",
    "id": "18********************2",
    "device_timestamp": "15**********54",
    "media_type": 1,
    "code": "Bk**********Vg",
    "client_cache_key": "MT********************.2",
    "filter_type": 0,
    "image_versions2": {
        "candidates": [
            {
                "width": 900,
                "height": 1125,
                "url": "https://instagram.fbah1-1.fna.fbcdn.net/vp/45c******************************D.2"
            },
            {
                "width": 240,
                "height": 300,
                "url": "https://instagram.fbah1-1.fna.fbcdn.net/vp/163******************************2"
            }
        ]
    },
    "original_width": 900,
    "original_height": 1125,
    "user": {
        "pk": 1**********2,
        "username": "a**********",
        "full_name": "",
        "is_private": false,
        "profile_pic_url": "https://instagram.fbah1-1.fna.fbcdn.net/vp/64c******************************02",
        "friendship_status": {
            "following": false,
            "outgoing_request": false,
            "is_bestie": false
        },
        "has_anonymous_profile_picture": false,
        "reel_auto_archive": "on",
        "is_unpublished": false,
        "is_favorite": false
    },
    "can_viewer_reshare": true,
    "caption": {
        "pk": "17********************72",
        "user_id": 1**********2,
        "text": "****************************************",
        "type": 1,
        "created_at": 1**********3,
        "created_at_utc": 15**********3,
        "content_type": "comment",
        "status": "Active",
        "bit_flags": 0,
        "user": {
            "pk": 1**********2,
            "username": "a**********",
            "full_name": "",
            "is_private": false,
            "profile_pic_url": "https://instagram.fbah1-1.fna.fbcdn.net/vp/64******************************8_n.jpg",
            "profile_pic_id": "17********************02",
            "friendship_status": {
                "following": false,
                "outgoing_request": false,
                "is_bestie": false
            },
            "has_anonymous_profile_picture": false,
            "reel_auto_archive": "on",
            "is_unpublished": false,
            "is_favorite": false
        },
        "did_report_as_spam": false,
        "media_id": "1********************8",
        "has_translation": true
    },
    "caption_is_edited": false,
    "like_count": 51,
    "has_liked": false,
    "comment_likes_enabled": false,
    "comment_threading_enabled": true,
    "has_more_comments": true,
    "next_max_id": "17**********1",
    "max_num_visible_preview_comments": 2,
    "preview_comments": [
        {
            "pk": "17**********5",
            "user_id": 44**********8,
            "text": "****************************** 😍❤️",
            "type": 0,
            "created_at": 1530359330,
            "created_at_utc": 1530359330,
            "content_type": "comment",
            "status": "Active",
            "bit_flags": 0,
            "user": {
                "pk": 4**********18,
                "username": "m**********d",
                "full_name": "**********✨",
                "is_private": true,
                "is_verified": false,
                "profile_pic_url": "https://instagram.fbah1-1.fna.fbcdn.net/vp/9c089f9605b4fc7a42dbccb940d39843/5BB3EB52/t51.2885-19/s150x150/26865901_1606689879439175_281618587532132352_n.jpg",
                "profile_pic_id": "1708583612356962920_449654518"
            },
            "did_report_as_spam": false,
            "media_id": "1813088998940374368"
        },
        {
            "pk": "17**********61",
            "user_id": 21**********95,
            "text": "******************************❤️",
            "type": 0,
            "created_at": 1530366241,
            "created_at_utc": 1530366241,
            "content_type": "comment",
            "status": "Active",
            "bit_flags": 0,
            "user": {
                "pk": 21**********95,
                "username": "s**********",
                "full_name": "B********************😍❤💙",
                "is_private": true,
                "is_verified": false,
                "profile_pic_url": "https://instagram.fbah1-1.fna.fbcdn.net/vp/db2**********6_a.jpg",
                "profile_pic_id": "15**********5"
            },
            "did_report_as_spam": false,
            "media_id": "1**********68",
            "has_translation": true
        }
    ],
    "can_view_more_preview_comments": true,
    "comment_count": 3,
    "photo_of_you": false,
    "can_viewer_save": true,
    "organic_tracking_token": "eyJ2******IifQ=="
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

27RU57 picture 27RU57  ·  12Comments

sagardalal21 picture sagardalal21  ·  39Comments

prichey picture prichey  ·  10Comments

zalkanorr picture zalkanorr  ·  12Comments

haliliceylan picture haliliceylan  ·  29Comments