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
882 stars 138 forks source link

Likes count and comments count stopped working #259

Closed michaelsier closed 2 years ago

michaelsier commented 3 years ago

Just recently, the API is returning values of -1, 0 and 1 for the count on Likes and Comments.

$publicProfile = $profile->getMedias(); print_r($publicProfile); ... [comments] => 0 [likes] => -1 [thumbnails] => Array

michaelsier commented 3 years ago

Bump @pgrimaud

michaelsier commented 3 years ago
Screen Shot 2021-10-25 at 4 54 29 pm
michaelsier commented 3 years ago

Help please anyone?

jellygnite commented 3 years ago

This is strange. I am running the component within a larger framework and am experiencing the same problem with Likes = -1. But when I run a simple example on its own I am getting the Likes to work.

jellygnite commented 3 years ago

I got this working but didn't actually change anything. I did physically delete the cache folder so that may have helped.

michaelsier commented 3 years ago

@pgrimaud @jellygnite I have tried deleting the cache folder but it made no difference for me. Comment count seems to be fine now, but likes are still -1.

jellygnite commented 3 years ago

perhaps it is related to the user login. I was having trouble with that and had to validate the user.

michaelsier commented 3 years ago

perhaps it is related to the user login. I was having trouble with that and had to validate the user.

It is authenticating and pulling the rest of the data in the response fine, just the likes count is obfuscated.

jellygnite commented 3 years ago

Hmm. I had the same issue yesterday on two projects. I got them both working and today one of them has reverted to the likes =-1 again. The pitfall of getting something working without knowing how.

jellygnite commented 3 years ago

https://github.com/pgrimaud/instagram-user-feed/blob/d0875905c139f9e122827060e19bb9f0de8e630e/src/Instagram/Hydrator/MediaHydrator.php#L75

I think this should be $media->setLikes($node->edge_liked_by->count);

I am not sure why sometimes Instagram includes the correct data with edge_media_preview_like but more often than not this value is being sent as '-1'.

michaelsier commented 3 years ago

I have tried changing the code to this but it didn't make any difference. I also downgraded to version 6.9.0 and it also didn't make any difference.

jellygnite commented 3 years ago

This was definitely the issue for me. See the raw data below before MediaHydrator.php has a look at it. Did you clear the cache folder after changing this line?

[edge_liked_by] => stdClass Object
(
    [count] => 24
)

[edge_media_preview_like] => stdClass Object
(
    [count] => -1
)

You can have a look at the raw data by echo('<pre>'.print_r($data,true).'</pre>'); after this line: https://github.com/pgrimaud/instagram-user-feed/blob/d0875905c139f9e122827060e19bb9f0de8e630e/src/Instagram/Api.php#L156

Check what data is being sent for edge_liked_by and edge_media_preview_like.

michaelsier commented 3 years ago

@jellygnite perhaps I'm clearing the wrong cache folder. which one are you clearing?

jellygnite commented 3 years ago

It all depends on what you have set up in this line: $cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');

michaelsier commented 3 years ago

@jellygnite I have found a second vendor folder within the app folder that had the library in it - which composer is not recognising nor updating, and in the mediahydrator line of code to edge_liked_by and now it is working! I can't tell you how many hours I have lost trying to fix this - amazing thank you!!

stale[bot] commented 2 years ago

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.

jellygnite commented 2 years ago

I notice this issue still exists in MediaProfileHydrator.php ~ line 50 $media->setLikes($node->edge_media_preview_like->count); should be $media->setLikes($node->edge_liked_by->count);