From 2025532a4e40701b4711ae0082e2e80fcf35d1dc Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 5 Jun 2019 13:03:39 +0300 Subject: [PATCH] Overload handling --- src/Request.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Request.php b/src/Request.php index 155504d..275f80c 100644 --- a/src/Request.php +++ b/src/Request.php @@ -117,6 +117,16 @@ protected function exec(){ $contents=$e->getResponse()->getBody()->getContents(); $temp=json_decode($contents,true); + + if (preg_match('/overload/i', $temp['error']['message'])) { + $this->auth(); + try { + return json_decode($this->send(),true); + } catch (RequestException $e) { + throw new Exception($temp); + } + } + if(!empty($temp)) { $temp['_method']=$this->type; $temp['_url']=$this->host.$this->path; @@ -133,4 +143,4 @@ protected function exec(){ throw new Exception(json_encode($temp)); } } -} \ No newline at end of file +}