Instagram-php-scraper: getMediaByUrl() and getMediaByCode() not working

Created on 21 May 2020  路  21Comments  路  Source: postaddictme/instagram-php-scraper

It seems that getMediaByUrl() and getMediaByCode() not working now.

I see [InstagramScraper\Exception\InstagramException] Media with this code does not exist (500) error for both functions

wontfix

Most helpful comment

the same problem here, but the curious is that in my local, all work, the response is OK, and have all data that i need, but when i put this in my Digital Ocean server, with the same configs, doesn't work.

All 21 comments

Same error..

Same! Sometimes it works, sometimes it doesn't...

Same error, I think that it's related with the IP that made the call but not sure yet.

Maybe it is related with ip but I saw some new generated media codes like that https://www.instagram.com/p/Bqj2ER_lsaqx8hNTQ8xa3FjmpPNyGReGKhSF7E0
I think, they are making test for some regions or IPs. This urls are not for all post media at now but it seems it will be at the future.
Other hand, cdninstagram.com can have some DNS problems. When i requested this domain I got 500 status code error on browser.

Same error...

Instagram no longer allows to view posts without logging in. You need to login.

Seems they soon will not allows to use instagram with login too )))

The same problem, I experienced with a redirect to a login page https://www.instagram.com/accounts/login/?next=/p/CAcbAKahSnz/%3F__a%3D1

@congkv Not sure if that's true ... I can still load public accounts and posts in the browser without being logged-in. https://www.instagram.com/redbull/ and https://www.instagram.com/p/B0YKatOontz/
Only navigation via click requires login.

the same problem here, but the curious is that in my local, all work, the response is OK, and have all data that i need, but when i put this in my Digital Ocean server, with the same configs, doesn't work.

Same error, I think that it's related with the IP that made the call but not sure yet.

I think it's not true dude, because i'm using proxy here, and nothing works.

I'm getting some kind of 404 errors for a code working previously. I've checked with sample instagram posts mentioned here (getting errors) and I updated instagram-php-scraper to the latest version (v0.9.10) and the error persists.

This is my exception (my app path is replaced by [MyAppPath]):

Fatal error: Uncaught exception 'InstagramScraper\Exception\InstagramException' with message 'Media with this code does not exist' in [MyAppPath]/vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php:590 Stack trace: #0 [MyAppPath]/index.php(125): InstagramScraper\Instagram->getMediaByUrl('https://www.ins...') #1 {main} thrown in [MyAppPath]//vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php on line 590

and this is the code I'm using (no user is logged on):

require __DIR__ . '/vendor/autoload.php';
$instagram = new \InstagramScraper\Instagram();
$media = $instagram->getMediaByUrl($instagram_url);
$img = $media->getImageHighResolutionUrl();
$relText = $media->getCaption();

@congkv Not sure if that's true ... I can still load public accounts and posts in the browser without being logged-in. https://www.instagram.com/redbull/ and https://www.instagram.com/p/B0YKatOontz/
Only navigation via click requires login.

@movAX13h Actually Instagram don't implement it for all. It depends on the region. I tried with proxy Japan then I got results like yours.

I am facing the same issue as well. When I visit a public account from browser I have no problem viewing its content, eg: https://www.instagram.com/p/CAf2RyvpsHG/ . When using the library I get an error 'Media with this code does not exist (500)'.

I tried using raw curl and instagram responds with 302 Redirect to login page. I don't know if instagram does an IP detection or agent but it seems like it is blocking bots.
Maybe it's relevant but I am using Digital Ocean as well.

Just to you know, i have the same issue, but now i try in my local PC and works like a charms, maybe is time to use Proxy?

Anyone know how to use it?

Just to you know, i have the same issue, but now i try in my local PC and works like a charms, maybe is time to use Proxy?

Anyone know how to use it?

No, as @congkv says, it seems that depends on the region or other aspects like the IP, the number of people that have logged in from this IP or something like this. We are currently using a pool of around 30 proxies and we are experiencing the same issues.

You have an example of how to use a proxy in the repository readme.md

Just to you know, i have the same issue, but now i try in my local PC and works like a charms, maybe is time to use Proxy?
Anyone know how to use it?

No, as @congkv says, it seems that depends on the region or other aspects like the IP, the number of people that have logged in from this IP or something like this. We are currently using a pool of around 30 proxies and we are experiencing the same issues.

You have an example of how to use a proxy in the repository readme.md

Are u using residential proxy?

Just to you know, i have the same issue, but now i try in my local PC and works like a charms, maybe is time to use Proxy?
Anyone know how to use it?

No, as @congkv says, it seems that depends on the region or other aspects like the IP, the number of people that have logged in from this IP or something like this. We are currently using a pool of around 30 proxies and we are experiencing the same issues.
You have an example of how to use a proxy in the repository readme.md

Are u using residential proxy?
It works good with residential proxies, but it is not cheap. Looks like IG bans the most popular hosting IPs.

After some tests with different residential proxy providers and with some of our own proxy servers I observed that the 500 error is only returned from some countries. I don't know if the restrictions are only deployed in some countries for some reason or the deploy is still pending.
For example, the restrictions are applied in USA and France but not in Canada and Italy.

694 Use this PR to fix this problem after logging in.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tvvinman picture Tvvinman  路  7Comments

Tripoli96 picture Tripoli96  路  5Comments

congkv picture congkv  路  4Comments

absfarah picture absfarah  路  5Comments

luengwaiban picture luengwaiban  路  5Comments