Skip to content

Commit c65c50b

Browse files
authored
Update helpers.php
1 parent 93a4535 commit c65c50b

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/helpers.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,31 @@ function sendRequest(string $url, string $method = "GET", array $params = [], ar
7575

7676
$response = curl_exec($ch);
7777

78+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
79+
$httpInfo = array_merge($httpInfo, curl_getinfo($ch));
80+
7881
if ($response === FALSE) {
7982
//echo "cURL Error: " . curl_error($ch);
80-
return false;
83+
return [
84+
'code' => 1,
85+
'message' => "cURL Error: " . curl_error($ch),
86+
'data' => [
87+
'httpCode' => $httpCode,
88+
'httpInfo' => $httpInfo,
89+
'response' => $response,
90+
],
91+
];
8192
}
8293

83-
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
84-
85-
$httpInfo = array_merge($httpInfo, curl_getinfo($ch));
86-
8794
curl_close($ch);
88-
89-
return $response;
95+
return [
96+
'code' => 0,
97+
'message' => 'success',
98+
'data' => [
99+
'response' => $httpCode,
100+
'httpInfo' => $httpInfo,
101+
'response' => $response,
102+
],
103+
];
90104
}
91105
}

0 commit comments

Comments
 (0)