Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using getProfile() #283

Open
haigooner95 opened this issue Apr 21, 2022 · 17 comments
Open

Error when using getProfile() #283

haigooner95 opened this issue Apr 21, 2022 · 17 comments
Assignees
Labels
wip Work in progress

Comments

@haigooner95
Copy link

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('/<script type="text\/javascript">window.__additionalDataLoaded([^,]*,(.+));</script>/', $html, $matches);
62|
63| if (!isset($matches[1])) {

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

@haigooner95 haigooner95 added the need-investigations Need investigations to classify label Apr 21, 2022
@nestl1ng
Copy link

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

@Rapid0s
Copy link

Rapid0s commented May 31, 2022

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

@aroy314
Copy link

aroy314 commented Jun 1, 2022

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 ?

@mmahdisz
Copy link

mmahdisz commented Jun 1, 2022

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

@karthick-tc
Copy link

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

@gurubobnz
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

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.

@pgrimaud
Copy link
Owner

pgrimaud commented Jun 2, 2022

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 pgrimaud added wip Work in progress and removed need-investigations Need investigations to classify labels Jun 2, 2022
@gurubobnz
Copy link
Contributor

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.

@pgrimaud
Copy link
Owner

pgrimaud commented Jun 2, 2022

Glad to read it. :D

@gurubobnz
Copy link
Contributor

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?

@pgrimaud
Copy link
Owner

pgrimaud commented Jun 2, 2022

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

@gurubobnz
Copy link
Contributor

Excellent. Yep, all sorted. Merci!

@aroy314
Copy link

aroy314 commented Jun 2, 2022

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

@Rapid0s
Copy link

Rapid0s commented Jun 3, 2022

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

@AgentSmith0
Copy link

This seems to be fixed in 6.16.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Work in progress
Projects
None yet
Development

No branches or pull requests

9 participants