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
881 stars 137 forks source link

Instagram respond with 429 #21

Closed denis-galas closed 6 years ago

denis-galas commented 6 years ago

Hello, I found your library very useful and I guess it can save my life:) But I have some troubles. Getting the instagram feed on my local machine works perfect, but since I tried it on server machine I always have this error message: PHP Fatal error: Uncaught exception 'GuzzleHttp\\Exception\\ClientException' with message 'Client error:GET https://www.instagram.com/miamiabeauty/resulted in a429 -response:\n<!DOCTYPE html>\n<html lang="en" class="no-js not-logged-in ">\n <head><meta charset="utf-8">\n <meta http-equiv= (truncated...)\n' in /var/www/html/marketing/public/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113\nStack trace:\n#0 /var/www/html/marketing/public/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\\Exception\\RequestException::create(Object(GuzzleHttp\\Psr7\\Request), Object(GuzzleHttp\\Psr7\\Response))\n#1 /var/www/html/marketing/public/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}(Object(GuzzleHttp\\Psr7\\Response))\n#2 /var/www/html/marketing/public/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\\Promise\\Promise::callHandler(1, Object(GuzzleHttp\\Psr7\\Response), Array)\n#3 /var/www/html/marketing/public/vendor/guzzlehttp/promises/src/TaskQueue.php(47): Guz in /var/www/html/marketing/public/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

It shouldn't be request limit issue, because that's just from first request. And I have this trouble only on the server machine, on local machine all fine. Can you please help me?

Thank you in advance.

pgrimaud commented 6 years ago

Hello @denis-galas,

That's weird... Is it a dedicated or shared server? Did you try with proxy?

denis-galas commented 6 years ago

Hello @pgrimaud,

Sorry for long time to not response. It's dedicated server, and I didn't try to use proxy. But I found another details - I can get successful response from instagram on server, but not always. When I'm not requesting Insta feed for a while then it works, but just few times (each time different amount of times)

pgrimaud commented 6 years ago

I guess it's a "Rate limit" error. Sometimes I got 429 errors with message : "The maximum number of requests per hour has been exceeded."

You can try to :

denis-galas commented 6 years ago

Main problem that this happens even after 1-2 refresh (on local machine I can do this hundred times and it will work each time), so it doesn't really looks like exceed of rate limit. Regarding cache - I thought this library caching by default. Isn't it?

pgrimaud commented 6 years ago

Caching is only here for cookies, not api calls. Are you using this library in CLI or directly on web pages?

denis-galas commented 6 years ago

It's directly on web page

pgrimaud commented 6 years ago

Here I guess : http://www.miamiabeauty.com/about/ ? Maybe you're not the only user to load the page?

I think you should use cache to avoid api calls every time the page is viewed. 4 calls per day is fine.

denis-galas commented 6 years ago

It's http://www.miamiabeauty.com/insta.php, and I'm sure that I'm only one because this script not used anywhere now

pgrimaud commented 6 years ago

Using a cache handler (eg. Redis, filesystem, etc...) with a TTL of 21600s will avoid this 429 errors.