instagram-user-feed icon indicating copy to clipboard operation
instagram-user-feed copied to clipboard

Error when using getProfile()

Open haigooner95 opened this issue 2 years ago • 17 comments

Version(s) affected: 6.13

Description
Instagram\Exception\InstagramFetchException : Profile #2 : Unable to extract JSON data

at /app/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlProfileDataFeed.php:64 60| 61| preg_match('/

64| throw new InstagramFetchException('Profile #2 : Unable to extract JSON data'); 65| } 66| 67| $data = json_decode($matches[1], false); 68|

haigooner95 avatar Apr 21 '22 04:04 haigooner95

This error was related to the Instagram profile you use to log in. You need to go to Instagram and check what it is connected with. In my case, when logging in, Instagram opened a modal window with a choice of date of birth, this was the problem

nestl1ng avatar May 24 '22 06:05 nestl1ng

I am getting Profile #1 : Unable to extract JSON data :(

Rapid0s avatar May 31 '22 18:05 Rapid0s

Hello, I have the same issue since yesterday 8PM : Profile #1 : Unable to extract JSON data (local environment and production server) After investigation, it comes from this regex in /app/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlProfileDataFeed.php:45 :

preg_match('/<script type="text\/javascript">window\._sharedData\s?=(.+);<\/script>/', $html, $matches);

  • When I try to dump the HTML it parses ($html), I cannot found the string "_sharedData"
  • I tried to go on the same URL myself with a browser and cannot find the string "_sharedData" either in the source code

Maybe Instagram updated its website and the regex should be updated ?

aroy314 avatar Jun 01 '22 08:06 aroy314

Hi, I have the same issue! I checked the above idea but I couldn't find a solution.

mmahdisz avatar Jun 01 '22 08:06 mmahdisz

Hi Team, Even am facing same issue "Unable to extract JSON data" . Kindly let me know if any solution or update

karthick-tc avatar Jun 01 '22 11:06 karthick-tc

Hello, I have the same issue since yesterday 8PM : Profile #1 : Unable to extract JSON data (local environment and production server) After investigation, it comes from this regex in /app/vendor/pgrimaud/instagram-user-feed/src/Instagram/Transport/HtmlProfileDataFeed.php:45 :

preg_match('/<script type="text\/javascript">window\._sharedData\s?=(.+);<\/script>/', $html, $matches);

  • When I try to dump the HTML it parses ($html), I cannot found the string "_sharedData"
  • I tried to go on the same URL myself with a browser and cannot find the string "_sharedData" either in the source code

Maybe Instagram updated its website and the regex should be updated ?

Yep, came to the exact same conclusion - following for updates. Will let you know also what I discover, if anything.

gurubobnz avatar Jun 01 '22 21:06 gurubobnz

Some more information. I was using version 6.2.2 and currently scraping two accounts is failing with this error - three accounts are not. We scrape once every two hours. I then upgraded to the latest (currently 6.13.1) and while this did not solve it it did lead me to discover something that may help.

I found that with version 6.2.2 I am able to scrape this account https://www.instagram.com/bulletproofconvertible, but with 6.13.1 I am not (I get this same "Unable to extract JSON data" error)

However, regardless of which version I use I am unable to scrape my own feed https://www.instagram.com/gurubobnz, which gives the same message.

I have logged onto the Instagram account that I am using as the scraper and there are no alerts or requirements for date of birth of any other thing I can see that might affect this.

gurubobnz avatar Jun 01 '22 21:06 gurubobnz

Some more information. We scrape the following URL's:

  • https://www.instagram.com/falloonbuilders
  • https://www.instagram.com/coach_jesse_the_body_architect
  • https://www.instagram.com/bowalleyfreerange
  • https://www.instagram.com/bulletproofconvertible
  • https://www.instagram.com/snuggle_me_tight_baby_gifts
  • https://www.instagram.com/roslynphysio

I upgraded to 6.13.1 and ALL of the above started to fail. Then when I rolled back to 6.2.2 the first four came right, with the final two still failing for the same reason. Perhaps this list will be helpful for someone else to verify whether they can or can't scrape those feeds.

These are listed in chronological order of when we set up the scraper. It may just be coincidence but it is the last two on the list that are failing - again, with 6.2.2 and 6.13.1. Surely if there is a chronological reason it's not to do with when we set up, but may have something to do with the creation date of the instagram account. Could be way off the mark, just throwing that out there as a possibility.

gurubobnz avatar Jun 02 '22 02:06 gurubobnz

Hey @gurubobnz

I just release a new version (6.15.0). I updated getProfile() method with last Instagram changes. Could you try it?

Thanks

pgrimaud avatar Jun 02 '22 09:06 pgrimaud

Hi, thank you for your prompt attention!

Yes, this has fixed the problem for me - all feeds that I listed above are now loading just fine.

Thanks heaps.

gurubobnz avatar Jun 02 '22 10:06 gurubobnz

Glad to read it. :D

pgrimaud avatar Jun 02 '22 10:06 pgrimaud

One final question please - even though 6.15.0 is the latest release on GitHub, when I install using composer I get 6.13.1 - is there a missing step to publish the latest version to the packagist database? I see that on https://packagist.org/packages/pgrimaud/instagram-user-feed it says "This package is auto-updated" - is it just a case of waiting?

gurubobnz avatar Jun 02 '22 11:06 gurubobnz

One final question please - even though 6.15.0 is the latest release on GitHub, when I install using composer I get 6.13.1 - is there a missing step to publish the latest version to the packagist database? I see that on https://packagist.org/packages/pgrimaud/instagram-user-feed it says "This package is auto-updated" - is it just a case of waiting?

Damn, sometimes packagist doesn't auto update. I forced the update and it should work now

pgrimaud avatar Jun 02 '22 11:06 pgrimaud

Excellent. Yep, all sorted. Merci!

gurubobnz avatar Jun 02 '22 11:06 gurubobnz

Works also for me in development and production ! Thanks for the quick update 🚀

aroy314 avatar Jun 02 '22 12:06 aroy314

Upgrade solved the "Profile #1 : Unable to extract JSON data" error for me also. Thanks :)

Rapid0s avatar Jun 03 '22 17:06 Rapid0s

This seems to be fixed in 6.16.6.

AgentSmith0 avatar Dec 31 '23 11:12 AgentSmith0