postaddictme / instagram-php-scraper

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

problem with getAccount() returning a 429 error #69

Closed edwardselig closed 7 years ago

edwardselig commented 7 years ago

PHP Catchable fatal error: Object of class stdClass could not be converted to string in /var/www/html/home/instagram-php-scraper-master/src/InstagramScraper/Instagram.php on line 25. I cannot figure out why this is happening.

Update: I seem to be getting a 429 error

edwardselig commented 7 years ago

I learned why this is happening. During a 429 response Instagram returns an object as the body of the response. Heres a snippet of the resonse:

Unirest\Response::__set_state(array( 'code' => 429, 'raw_body' => '{"message": "Please wait a few minutes before you try again.", "status": "fail"}', 'body' => stdClass::__set_state(array( 'message' => 'Please wait a few minutes before you try again.', 'status' => 'fail', )),

edwardselig commented 7 years ago

Here is a suggested solution: https://github.com/edwardselig/instagram-php-scraper/commit/13af7c8a0097e0922422e08837e969ed6497b625

edwardselig commented 7 years ago

also I did some testing and it seems like the rate limit is around 3000 requests with a timeout of 80 seconds. I dont know what interval the 3000 request have to be in.