From c2d4eb0691e1a314497368ca816b834d8abc1bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Abi-Khalil?= Date: Thu, 30 Jan 2025 15:25:47 +0100 Subject: [PATCH 1/2] Refs #BO-4159 - This PR add throw if we have error wih twitter api --- src/TwitterOAuth.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/TwitterOAuth.php b/src/TwitterOAuth.php index 3f0c31aa..65d76e9e 100644 --- a/src/TwitterOAuth.php +++ b/src/TwitterOAuth.php @@ -533,12 +533,17 @@ private function makeRequests( do { $this->sleepIfNeeded(); $result = $this->oAuthRequest($url, $method, $parameters, $json); + $response = JsonDecoder::decode($result, $this->decodeJsonAsArray); $this->response->setBody($response); $this->attempts++; // Retry up to our $maxRetries number if we get errors greater than 500 (over capacity etc) } while ($this->requestsAvailable()); + if (isset($response->status) && $response->status != 200) { + throw new TwitterOAuthException($result); + } + return $response; } From 373bf184a968786fa04ae433d824e2c60db30721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Abi-Khalil?= Date: Thu, 30 Jan 2025 17:44:40 +0100 Subject: [PATCH 2/2] Remove useless new line. --- src/TwitterOAuth.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TwitterOAuth.php b/src/TwitterOAuth.php index 65d76e9e..fa27c4b2 100644 --- a/src/TwitterOAuth.php +++ b/src/TwitterOAuth.php @@ -533,7 +533,6 @@ private function makeRequests( do { $this->sleepIfNeeded(); $result = $this->oAuthRequest($url, $method, $parameters, $json); - $response = JsonDecoder::decode($result, $this->decodeJsonAsArray); $this->response->setBody($response); $this->attempts++;