| @@ -1,10 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm\Core\Util; |
| 4 | 4 | |
| 5 | -final class HttpHelper { | |
| 6 | - public static function post($url, $data, $headers = null, $options = null) { | |
| 5 | +final class HttpHelper | |
| 6 | +{ | |
| 7 | + public static function post($url, $data, $headers = null, $options = null) | |
| 8 | + { | |
| 7 | 9 | $defaultOptions = [ |
| 8 | 10 | 'headers' => $headers, |
| 9 | 11 | 'body' => $data, |
| 10 | 12 | 'timeout' => 30 |
| @@ -16,9 +18,9 @@ | ||
| 16 | 18 | return $requestReponse; |
| 17 | 19 | } |
| 18 | 20 | // $responseCode = wp_remote_retrieve_response_code($requestReponse); |
| 19 | 21 | // if (!\is_null($responseCode) && $responseCode != 200) { |
| 20 | - // return wp_remote_retrieve_response_message($requestReponse); | |
| 22 | + // return wp_remote_retrieve_response_message($requestReponse); | |
| 21 | 23 | // } |
| 22 | 24 | $responseBody = wp_remote_retrieve_body($requestReponse); |
| 23 | 25 | $jsonData = json_decode($responseBody); |
| 24 | 26 | return \is_null($jsonData) ? $responseBody : $jsonData; |
| @@ -23,9 +25,10 @@ | ||
| 23 | 25 | $jsonData = json_decode($responseBody); |
| 24 | 26 | return \is_null($jsonData) ? $responseBody : $jsonData; |
| 25 | 27 | } |
| 26 | 28 | |
| 27 | - public static function get($url, $data, $headers = null, $options = null) { | |
| 29 | + public static function get($url, $data, $headers = null, $options = null) | |
| 30 | + { | |
| 28 | 31 | $defaultOptions = [ |
| 29 | 32 | 'headers' => $headers, |
| 30 | 33 | 'body' => $data, |
| 31 | 34 | 'timeout' => 30 |
| @@ -36,9 +39,9 @@ | ||
| 36 | 39 | return $requestReponse; |
| 37 | 40 | } |
| 38 | 41 | // $responseCode = wp_remote_retrieve_response_code($requestReponse); |
| 39 | 42 | // if (!\is_null($responseCode) && $responseCode != 200) { |
| 40 | - // return wp_remote_retrieve_response_message($requestReponse); | |
| 43 | + // return wp_remote_retrieve_response_message($requestReponse); | |
| 41 | 44 | // } |
| 42 | 45 | $responseBody = wp_remote_retrieve_body($requestReponse); |
| 43 | 46 | $jsonData = json_decode($responseBody); |
| 44 | 47 | return \is_null($jsonData) ? $responseBody : $jsonData; |
| @@ -43,9 +46,10 @@ | ||
| 43 | 46 | $jsonData = json_decode($responseBody); |
| 44 | 47 | return \is_null($jsonData) ? $responseBody : $jsonData; |
| 45 | 48 | } |
| 46 | 49 | |
| 47 | - public static function request($url, $type, $data, $headers = null, $options = null) { | |
| 50 | + public static function request($url, $type, $data, $headers = null, $options = null) | |
| 51 | + { | |
| 48 | 52 | $defaultOptions = [ |
| 49 | 53 | 'method' => $type, |
| 50 | 54 | 'headers' => $headers, |
| 51 | 55 | 'body' => $data, |
| @@ -57,9 +61,9 @@ | ||
| 57 | 61 | return $requestReponse; |
| 58 | 62 | } |
| 59 | 63 | // $responseCode = wp_remote_retrieve_response_code($requestReponse); |
| 60 | 64 | // if (!\is_null($responseCode) && $responseCode != 200) { |
| 61 | - // return wp_remote_retrieve_response_message($requestReponse); | |
| 65 | + // return wp_remote_retrieve_response_message($requestReponse); | |
| 62 | 66 | // } |
| 63 | 67 | $responseBody = wp_remote_retrieve_body($requestReponse); |
| 64 | 68 | $jsonData = json_decode($responseBody); |
| 65 | 69 | return \is_null($jsonData) ? $responseBody : $jsonData; |