Closed michaelsier closed 2 years ago
Bump @pgrimaud
Help please anyone?
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.
I got this working but didn't actually change anything. I did physically delete the cache folder so that may have helped.
@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.
perhaps it is related to the user login. I was having trouble with that and had to validate the user.
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.
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.
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'.
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.
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.
@jellygnite perhaps I'm clearing the wrong cache folder. which one are you clearing?
It all depends on what you have set up in this line:
$cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');
@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!!
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.
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);
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