src/Support/Web/WebRequest.php
/**
     * Executes this request with the `GET`  request method and returns the response.
     *
     * @param string $format The type of formatting to use for posting (`json` or `urlencoded`).
     *
     * @return WebResponse
     * @throws WebRequestException Thrown for network, connection, or configuration errors.
     */
Executes this request with the `GET`  request method and returns the response.
@param string $format The type of formatting to use for posting (`json` or `urlencoded`).

@return WebResponse
@throws WebRequestException Thrown for network, connection, or configuration errors.
Executes this request with the ` GET ` request method and returns the response . @param string $format The type of formatting to use for posting ( ` json ` or ` urlencoded ` ) . @return WebResponse @throws WebRequestException Thrown for network connection or configuration errors .
public function post($fields = [], $format = 'urlencoded') {
        $format = strtolower($format);
        $headers = [];
        if ($format === 'json') {
            if (is_array($fields)) $fields = json_encode($fields, JSON_UNESCAPED_SLASHES);
            $headers['content-type'] = 'application/json';
        }
        elseif ($format === 'urlencoded') {
            if (is_array($fields)) $fields = http_build_query($fields);
            $headers['content-type'] = 'application/x-www-form-urlencoded';
        }
        else $headers['content-type'] = $format;
        return $this->execute('post', [ CURLOPT_POSTFIELDS => $fields ], $headers);
    }
public function post ( $ fields = [ ] , $ format = 'urlencoded' ) { $ format = strtolower ( $ format ) ; $ headers = [ ] ; if ( $ format === 'json' ) { if ( is_array ( $ fields ) ) $ fields = json_encode ( $ fields , JSON_UNESCAPED_SLASHES ) ; $ headers [ 'content-type' ] = 'application/json' ; } elseif ( $ format === 'urlencoded' ) { if ( is_array ( $ fields ) ) $ fields = http_build_query ( $ fields ) ; $ headers [ 'content-type' ] = 'application/x-www-form-urlencoded' ; } else $ headers [ 'content-type' ] = $ format ; return $ this -> execute ( 'post' , [ CURLOPT_POSTFIELDS => $ fields ] , $ headers ) ; }
Executes this request with the `GET`  request method and returns the response.
Executes this request with the ` GET ` request method and returns the response .
// If the format is 'json', convert arrays to a JSON string // If the format is 'urlencoded', convert arrays to a query string // If the format is anything else, set the content type directly // Perform the request