Skip to content
This repository was archived by the owner on Nov 2, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/CloudFlare/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,20 @@ protected function request($path, array $data = [], $method = 'get')
$information = curl_getinfo($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

$response = json_decode($http_result);

if (in_array($http_code, [401, 403])) {
throw new UnauthorizedException('You do not have permission to perform this request');
if (!$response) {
throw new UnauthorizedException('You do not have permission to perform this request');
} else {
$response->success = false;
$error_obj = new \stdClass();
$error_obj->code = 0;
$error_obj->message = $response->error;
$response->errors[] = $error_obj;
}
}

$response = json_decode($http_result);
if (!$response) {
$response = new \stdClass();
$response->success = false;
Expand Down