Reputation: 1951
I have been using the Instagram API for some time, but I see a certain url that is causing me problems. So far, I have been pulling the shortcode from a url like so:
const instagramRegex = /https:\/\/www.instagram.com\/p\/([\w-]+)\/?/g;
let shortcode = instaRegex.exec(url)[1];
This returns the shortcode as expected, something that looks like BU89NChA8Cz from a url like https://www.instagram.com/p/BU89NChA8Cz/. The problem now is, the following url returns html, not a json response as expected. It is also not likely a shortcode.
Problem url: https://www.instagram.com/p/BTC-qwADp7WmlJ06W_Z_B59Bxbpml31t_fb-3U0/
The regex still returns the "shortcode" as expected: BTC-qwADp7WmlJ06W_Z_B59Bxbpml31t_fb-3U0, but this is not what I want as it is a "Page Not Found" HTML doc, not an api response.
I have also tried variations of this larger code, splitting on "_", but each of those returns "invalid media id"
What am I doing wrong?
Upvotes: 2
Views: 2223
Reputation: 12952
It is a URL from a private profile, so you cannot view it.
Usually if the shortcode is that long it is from a Instagram user that is private, that URL will work if you are allowed by that user and you are logged into instagram.com
Upvotes: 2