pgrimaud / instagram-user-feed

This is a scrapper to easily fetch any feed and interact with Instagram (like, follow, etc.) without OAuth for PHP.
MIT License
880 stars 137 forks source link

Error when there is no "sessionId" cookie #341

Open renvivancos opened 2 years ago

renvivancos commented 2 years ago

Description
When the sessionId cookie is not set, there is an error : Call to a member function getExpires() on null in Instagram\Api->login() (line 166 of /var/www/html/vendor/pgrimaud/instagram-user-feed/src/Instagram/Api.php).

Possible Solution
I don't know very well Instagram and the different cookies set but I found a solution which works for me, but I'm not sure it's the best and if that there are no side effects : On line 166 just also check if variable $session is empty.

midweste commented 2 years ago

We took a quick look at the cookies returned, seems that Insta is returning "mid" as one of the cookies with hashed code. Could be this is the new name for sessionId

renvivancos commented 2 years ago

Ok, thanks. I'll check it when i'll have time, and keep you informed.

midweste commented 2 years ago

After changing the sessionId to mid, we're having other issues, so not quite sure that is the right session

renvivancos commented 2 years ago

Ok, with my quick fix I don't have the error anymore, but I don't get the contents from instagram. I'll try to look at it maybe next week if I have time.

audreybzt commented 2 years ago

Hello,

I've the same problem.

"sessionId" cookie is not set in my CookieJar.

I've approved my device with "checkpoint challenge" method.

pgrimaud commented 2 years ago

Ok, with my quick fix I don't have the error anymore, but I don't get the contents from instagram. I'll try to look at it maybe next week if I have time.

Maybe, just a quick check if $session is not null?

almod90 commented 2 years ago

Looks like it's the same error as in https://github.com/pgrimaud/instagram-user-feed/issues/305

aroy314 commented 1 year ago

Hello, We updated to 6.16.4 and we are experiencing the same issue for new connections. Could we please have :

163             $session = $cookies->getCookieByName('mid');
164
165             // Session expired (should never happened, Instagram TTL is ~ 1 year)
166             if ($session && $session->getExpires() < time()) {
167                 $this->logout($username);
168                 $this->login($username, $password, $imapClient);
169             }

Thanks 🙏