# bit-form/1.2/includes/Core/Util/HttpHelper.php

Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator &amp; Custom Form Builder, version 1.2. 60 lines.

- Page: https://pluginprobe.com/plugins/bit-form/1.2/code/includes/Core/Util/HttpHelper.php
- Raw: https://pluginprobe.com/plugins/bit-form/1.2/raw/includes/Core/Util/HttpHelper.php
- Modified: 2020-09-05T12:07:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bit-form/1.2/code/includes/Core/Util/HttpHelper.php#L10-L20`.

```php
<?php
namespace BitCode\BitForm\Core\Util;

final class HttpHelper
{
    public static function post($url, $data, $headers = null, $options = null)
    {
        $defaultOptions =[
            'headers' => $headers,
            'body' => $data,
            "timeout" => 30
        ];
        
        $options = wp_parse_args($options, $defaultOptions);
        $requestReponse = wp_remote_post($url, $options);

        if (is_wp_error($requestReponse)) {
            return $requestReponse;
        }
        $responseBody = wp_remote_retrieve_body($requestReponse);
        $jsonData = json_decode($responseBody);
        return \is_null($jsonData) ? $responseBody : $jsonData;
    }

    public static function get($url, $data, $headers = null, $options = null)
    {
        $defaultOptions =[
            'headers' => $headers,
            'body' => $data,
            "timeout" => 30
        ];
        $options = wp_parse_args($options, $defaultOptions);
        $requestReponse = wp_remote_get($url, $options);
        if (is_wp_error($requestReponse)) {
            return $requestReponse;
        }
        $responseBody = wp_remote_retrieve_body($requestReponse);
        $jsonData = json_decode($responseBody);
        return \is_null($jsonData) ? $responseBody : $jsonData;
    }

    public static function request($url, $type, $data, $headers = null, $options = null)
    {
        $defaultOptions =[
            'method' => $type,
            'headers' => $headers,
            'body' => $data,
            "timeout" => 30
        ];
        $options = wp_parse_args($options, $defaultOptions);
        $requestReponse = wp_remote_request($url, $options);
        if (is_wp_error($requestReponse)) {
            return $requestReponse;
        }
        $responseBody = wp_remote_retrieve_body($requestReponse);
        $jsonData = json_decode($responseBody);
        return \is_null($jsonData) ? $responseBody : $jsonData;
    }
}

```
