public function updateVenuesService() { while (1) { if ($this->spider->getCurrentRateLimit() == 0) { // wait for 15min if we hit the rate limit $message = 'Warning: Rate limit hit! Script will pause for 15mins.'; \Cli::error($message); $this->spider->emailReport($message); \Cli::wait(1800); } $success = $this->spider->updateVenues(); if (!$success) { $message = 'Warning: Probably hit the rate limit. Foursquare headers incorrect at the moment! Script will pause for 15mins.'; \Cli::error($message); $this->spider->emailReport($message); \Cli::wait(1800); } else { \Cli::wait(5, true); } } }