/** * @param string $apiSubUrl * @param array $params * @param array $headers * @param bool $delay * @param bool $error * @return array * @throws \Exception */ public function api($apiSubUrl, $params = [], $headers = [], $delay = false, $error = false) { $params['lang'] = 'ru'; $countError = 0; $e = new \Exception(); while ($countError < 5) { try { return parent::api($apiSubUrl, 'POST', $params, $headers, $delay)['response']; } catch (\Exception $e) { if ($error) { throw $e; } if ($e->getCode()) { if ($e->getCode() == 6) { sleep(2); return $this->api($apiSubUrl, $params, $headers, $delay, true); } else { throw $e; } } elseif ($countError > 0) { $this->big = true; } ++$countError; } } throw $e; }