Instagram-php-scraper: Fatal Error to Call to a member function getId()?

Created on 11 Feb 2020  路  8Comments  路  Source: postaddictme/instagram-php-scraper

So,
I'm trying to bring several comments from a post, but whenever I try, on a specific lastid, it generates an error on the server

the postcode is => B5qw8pwlNQY and the lastid is => 17859317416616905

Fatal error: Uncaught Error: Call to a member function getId() on bool...

In some publications this error happens, and completely stops bringing comments :/.

All 8 comments

Yeah, but the error is thrown in your code (InstaApi.php:142) and not in the library code.

Anyway, check if that post actually exists / isn't on private account (which you can't access while scraping) - I'm getting 404 when trying to get https://www.instagram.com/p/B5qw8pwlNQY/

https://www.instagram.com/p/B8jlvqQhYVK, here is the new link, i can't take all comments :/

You can't get all comments (but you can get some) or you can't get any comments at all?

I've looked into the methods related to getting comments and already found 2 bugs, but I'm not sure if they're related to your issue (I will make pull requests later).

First, thanks for your attention man...

I have a project stopped so: /

I can get some comments, i'm trying get 60 comments per requests, so, i get 60 comments and storage the "lastid" of the comments, after, i call my function again, but now with "lastid" of the last comment, everything works, until in some "lastid", return of the method "getMediaCommentsByCode" is a empty array, and i don't know why.

So my code leak...

In some publications all is perfect, i get 30k comments, normal, but in others, can't, and all break.

It seems to me that some specific ids are the problem, because it always hangs on the same comment ids.

Okay, I get it. It's actually one of these 2 bugs I mentioned. I'll post more info & propose a pull request tomorrow.

Thank you very much, I really need this, you are awesome, please keep me posted :)

Okay, so the thing is, some comments on Instagram are hidden (marked as spam?) and can't be retrieved (I'm not sure what's the reason, I just see that it works that way).

If every comment can be retrieved, you can run getMediaCommentsByCode('...', 15), whichs makes a single request, gets 15 comments and that's it.

But the response sometimes contains fewer comments, and in that case the script stays in while loop, trying to make further requests until all 15 comments are collected (or until there's no furher comments). And this is fine.

The problem is, if a particular response doesn't contain any comments, getMediaCommentsByCode() returns an empty array, wrongly assuming that the media has no comments at all.

100% working, thank you so much man!

You are nice!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phoenixh picture phoenixh  路  5Comments

fsjdg picture fsjdg  路  8Comments

Tvvinman picture Tvvinman  路  7Comments

manchdev picture manchdev  路  9Comments

eelcol picture eelcol  路  5Comments