|
8 | 8 | * Time: 23:16 |
9 | 9 | */ |
10 | 10 | if (!function_exists('sendSimpleRequest')) { |
11 | | - /** |
12 | | - * Function sendSimpleRequest |
13 | | - * |
14 | | - * @param string $url URL Target Endpoint |
15 | | - * @param string|array|object $data Array Data to Request |
16 | | - * @param string $method GET or POST |
17 | | - * |
18 | | - * @return bool|string|null |
19 | | - * @author : 713uk13m <[email protected]> |
20 | | - * @copyright: 713uk13m <[email protected]> |
21 | | - * @time : 08/03/2021 20:38 |
22 | | - */ |
23 | | - function sendSimpleRequest(string $url = '', $data = [], string $method = 'GET') |
24 | | - { |
25 | | - $target = (!empty($data) && (is_array($data) || is_object($data))) ? $url . '?' . http_build_query($data) : $url; |
26 | | - $method = mb_strtoupper($method); |
27 | | - $curl = curl_init(); |
28 | | - curl_setopt_array($curl, array( |
29 | | - CURLOPT_URL => $target, |
30 | | - CURLOPT_RETURNTRANSFER => true, |
31 | | - CURLOPT_ENCODING => "", |
32 | | - CURLOPT_MAXREDIRS => 10, |
33 | | - CURLOPT_TIMEOUT => 30, |
34 | | - CURLOPT_CUSTOMREQUEST => $method, |
35 | | - CURLOPT_POSTFIELDS => "", |
36 | | - CURLOPT_HTTPHEADER => array(), |
37 | | - )); |
38 | | - $response = curl_exec($curl); |
39 | | - $err = curl_error($curl); |
40 | | - curl_close($curl); |
41 | | - if ($err) { |
42 | | - $message = "cURL Error #: " . $err; |
43 | | - if (function_exists('log_message')) { |
44 | | - log_message('error', $message); |
45 | | - } |
| 11 | + /** |
| 12 | + * Function sendSimpleRequest |
| 13 | + * |
| 14 | + * @param string $url URL Target Endpoint |
| 15 | + * @param string|array|object $data Array Data to Request |
| 16 | + * @param string $method GET or POST |
| 17 | + * |
| 18 | + * @return bool|string|null |
| 19 | + * @author : 713uk13m <[email protected]> |
| 20 | + * @copyright: 713uk13m <[email protected]> |
| 21 | + * @time : 08/03/2021 20:38 |
| 22 | + */ |
| 23 | + function sendSimpleRequest(string $url = '', $data = [], string $method = 'GET') |
| 24 | + { |
| 25 | + $target = (!empty($data) && (is_array($data) || is_object($data))) ? $url . '?' . http_build_query($data) : $url; |
| 26 | + $method = mb_strtoupper($method); |
| 27 | + $curl = curl_init(); |
| 28 | + curl_setopt_array($curl, array( |
| 29 | + CURLOPT_URL => $target, |
| 30 | + CURLOPT_RETURNTRANSFER => true, |
| 31 | + CURLOPT_ENCODING => "", |
| 32 | + CURLOPT_MAXREDIRS => 10, |
| 33 | + CURLOPT_TIMEOUT => 30, |
| 34 | + CURLOPT_CUSTOMREQUEST => $method, |
| 35 | + CURLOPT_POSTFIELDS => "", |
| 36 | + CURLOPT_HTTPHEADER => array(), |
| 37 | + )); |
| 38 | + $response = curl_exec($curl); |
| 39 | + $err = curl_error($curl); |
| 40 | + curl_close($curl); |
| 41 | + if ($err) { |
| 42 | + $message = "cURL Error #: " . $err; |
| 43 | + if (function_exists('log_message')) { |
| 44 | + log_message('error', $message); |
| 45 | + } |
46 | 46 |
|
47 | | - return null; |
48 | | - } |
| 47 | + return null; |
| 48 | + } |
49 | 49 |
|
50 | | - return $response; |
51 | | - } |
| 50 | + return $response; |
| 51 | + } |
52 | 52 | } |
53 | 53 | if (!function_exists('getIpAddress')) { |
54 | | - /** |
55 | | - * Function getIpAddress |
56 | | - * |
57 | | - * @param bool $convertToInteger |
58 | | - * |
59 | | - * @return bool|int|string |
60 | | - * @author : 713uk13m <[email protected]> |
61 | | - * @copyright: 713uk13m <[email protected]> |
62 | | - * @time : 09/20/2021 10:36 |
63 | | - */ |
64 | | - function getIpAddress(bool $convertToInteger = false) |
65 | | - { |
66 | | - $ip = new nguyenanhung\MyRequests\Ip(); |
67 | | - return $ip->getIpAddress($convertToInteger); |
68 | | - } |
| 54 | + /** |
| 55 | + * Function getIpAddress |
| 56 | + * |
| 57 | + * @param bool $convertToInteger |
| 58 | + * |
| 59 | + * @return bool|int|string |
| 60 | + * @author : 713uk13m <[email protected]> |
| 61 | + * @copyright: 713uk13m <[email protected]> |
| 62 | + * @time : 09/20/2021 10:36 |
| 63 | + */ |
| 64 | + function getIpAddress(bool $convertToInteger = false) |
| 65 | + { |
| 66 | + $ip = new nguyenanhung\MyRequests\Ip(); |
| 67 | + return $ip->getIpAddress($convertToInteger); |
| 68 | + } |
69 | 69 | } |
0 commit comments