postaddictme / instagram-php-scraper

Get account information, photos, videos, stories and comments.
https://packagist.org/packages/raiym/instagram-php-scraper
MIT License
3.08k stars 798 forks source link

getOwnerId() bug #208

Closed aik27 closed 6 years ago

aik27 commented 6 years ago

getOwnerId() return incorrect ids. Just follow my logic.

Look at this code:

$Instagram = new \InstagramScraper\Instagram();
$media = $Instagram->getMediasByTag('shinomontage');
foreach ($media as $key=>$item) {
    echo '<a href="'.$item->getLink().'">';
    echo $item->getOwnerId();
    echo '</a><br />';
}

For now, It will return 11 similar Owner ID and 1 different.

Result:

2147483647
2147483647
2147483647
2147483647
2147483647
2147483647
1540731511
2147483647
2147483647
2147483647
2147483647
2147483647

I thought, ok, 1 man posted 11 images in sequence. But if you follow links, you will see - most of this images posted by different accounts.

Tested at v0.8.5

aik27 commented 6 years ago

I found the reason. Some accounts have ID outside integer range (−2 147 483 648 to 2 147 483 647). For example: 6 271 847 937. So type conversion to INT always return 2 147 483 647 (maximum range value). Affected this functions:

account->getId() account->initPropertiesCustom()

And maybe others.

raiym commented 6 years ago

https://github.com/postaddictme/instagram-php-scraper/commit/09d6cb586de189f507bf466f1ca98307f4d6af49