This commit is contained in:
Evgeny Zinoviev 2021-02-25 18:04:38 +03:00
parent b75f1a4ab8
commit 6ed0e6e9cf

View File

@ -28,7 +28,7 @@ class FastDNS {
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch); curl_close($ch);
$response = jsonDecode($body); $response = json_decode($body, true);
if ($code != 200) if ($code != 200)
throw new FastDNSException($response['message'], $response['code']); throw new FastDNSException($response['message'], $response['code']);
@ -274,7 +274,7 @@ class FastDNS {
if (!empty($params)) { if (!empty($params)) {
if ($method === 'POST' || $method == 'PUT') { if ($method === 'POST' || $method == 'PUT') {
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, jsonEncode($params)); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
} else if ($method === 'GET') { // Probably never used } else if ($method === 'GET') { // Probably never used
$url .= '?'.http_build_query($params); $url .= '?'.http_build_query($params);
} }
@ -288,7 +288,7 @@ class FastDNS {
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch); curl_close($ch);
$response = jsonDecode($body); $response = json_decode($body, true);
if ($code >= 400) { if ($code >= 400) {
if (!empty($response['code']) && !empty($response['message'])) { if (!empty($response['code']) && !empty($response['message'])) {
$message = $response['message']; $message = $response['message'];