Skip to content

Commit cb6a7e0

Browse files
author
Dirk Luijk
committed
Implemented TwitterException in case of error response
1 parent b1bad20 commit cb6a7e0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

TwitterOAuth/TwitterOAuth.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ protected function buildRequestHeader()
250250
/**
251251
* Send GET or POST requests to Twitter API
252252
*
253+
* @throws Exception\TwitterException
253254
* @return mixed Response output with the selected format
254255
*/
255256
protected function sendRequest()
@@ -281,6 +282,14 @@ protected function sendRequest()
281282

282283
unset($options, $c);
283284

285+
$response = json_decode($response);
286+
287+
if(isset($response->errors)) {
288+
foreach($response->errors as $error) {
289+
throw new TwitterException($error->message, $error->code);
290+
}
291+
}
292+
284293
return $response;
285294
}
286295
}

0 commit comments

Comments
 (0)