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

PHP Strict Standards: Non-static method InstagramScraper\Instagram::getLocationById() should not be called statically #185

Closed amauryleproux closed 6 years ago

amauryleproux commented 6 years ago

Guys does anyone has an idea why I get this error when I try to get Media by location id please?

Thanks

AlexMiroshnikov commented 6 years ago

You get this error because getLocationById() is not a static method, so it must be applied to an instance of Instagram class. Instead of Instagram::getLocationById() use the following:

$ig = Instagram::withCredentials(...);
$ig->getLocationById(...);

Btw, this is also quite obvious ;-) .

amauryleproux commented 6 years ago

I really start to love you haha thanks again but this time I found it before you replied :p but it's not working anyway :/

I got this : PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /Applications/MAMP/htdocs/instagram-php-scraper/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Item.php:39

AlexMiroshnikov commented 6 years ago

@amauryleproux Is it the complete error message? Don't you have a longer error stacktrace?

amauryleproux commented 6 years ago

There is the whole message:

PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /Applications/MAMP/htdocs/instagram-php-scraper/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Item.php:39 Stack trace:

0 /Applications/MAMP/htdocs/instagram-php-scraper/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Item.php(39): DateTime->__construct()

1 [internal function]: phpFastCache\Drivers\Files\Item->__construct(Object(phpFastCache\Drivers\Files\Driver), 'amauryleproux')

2 /Applications/MAMP/htdocs/instagram-php-scraper/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/StandardPsr6StructureTrait.php(56): Reflection in /Applications/MAMP/htdocs/instagram-php-scraper/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Item.php on line 39

Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /Applications/MAMP/htdocs/instagram-php-scraper/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Item.php:39 Stack trace:

0 /Applications/MAMP/htdocs/instagram-php-scraper/vendor/phpfastcache/phpfastcache/src/phpFastCache/Drivers/Files/Item.php(39): DateTime->__construct()

1 [internal function]: phpFastCache\Drivers\Files\Item->__construct(Object(phpFastCache\Drivers\Files\Driver), 'amauryleproux')

AlexMiroshnikov commented 6 years ago

Try to either to add a default timezone to you php ini file or set it in your script via date_default_timezone_set() command.

amauryleproux commented 6 years ago

You rock! Thanks again :)

AlexMiroshnikov commented 6 years ago

@amauryleproux You're welcome :)

raiym commented 6 years ago

Thank you @AlexMiroshnikov @amauryleproux I have updated examples: https://github.com/postaddictme/instagram-php-scraper/tree/master/examples