src/Request/CurlRequestUtil.php
public function postRequest(string $url, array $requestHeaders = [], array $postFields = [], bool $returnResponseHeaders = false)
    {
        $handle = $this->createCurlHandle($url);

        if (Config::get('hpProxy')) {
            $handle->setOption(CURLOPT_PROXY, Config::get('hpProxy'));
        }

        if ($returnResponseHeaders) {
            $handle->setOption(CURLOPT_HEADER, true);
        }

        if (!empty($requestHeaders)) {
            $handle->setOption(CURLOPT_HTTPHEADER, $this->prepareHeaders($requestHeaders));
        }

        if (!empty($postFields)) {
            $handle->setOption(CURLOPT_POST, true);
            $handle->setOption(CURLOPT_POSTFIELDS, http_build_query($postFields));
        }

        $response = $handle->execute();

        $statusCode = $handle->getInfo(CURLINFO_HTTP_CODE);
        $handle->close();

        if ($response && $returnResponseHeaders) {
            return $this->splitResponseHeaderAndBody($response, $statusCode);
        }

        return $response;
    }
public function postRequest(string $url, array $requestHeaders = [], array $postFields = [], bool $returnResponseHeaders = false)
    {
        $handle = $this->createCurlHandle($url);

        if (Config::get('hpProxy')) {
            $handle->setOption(CURLOPT_PROXY, Config::get('hpProxy'));
        }

        if ($returnResponseHeaders) {
            $handle->setOption(CURLOPT_HEADER, true);
        }

        if (!empty($requestHeaders)) {
            $handle->setOption(CURLOPT_HTTPHEADER, $this->prepareHeaders($requestHeaders));
        }

        if (!empty($postFields)) {
            $handle->setOption(CURLOPT_POST, true);
            $handle->setOption(CURLOPT_POSTFIELDS, http_build_query($postFields));
        }

        $response = $handle->execute();

        $statusCode = $handle->getInfo(CURLINFO_HTTP_CODE);
        $handle->close();

        if ($response && $returnResponseHeaders) {
            return $this->splitResponseHeaderAndBody($response, $statusCode);
        }

        return $response;
    }
public function postRequest ( string $ url , array $ requestHeaders = [ ] , array $ postFields = [ ] , bool $ returnResponseHeaders = false ) { $ handle = $ this -> createCurlHandle ( $ url ) ; if ( Config :: get ( 'hpProxy' ) ) { $ handle -> setOption ( CURLOPT_PROXY , Config :: get ( 'hpProxy' ) ) ; } if ( $ returnResponseHeaders ) { $ handle -> setOption ( CURLOPT_HEADER , true ) ; } if ( ! empty ( $ requestHeaders ) ) { $ handle -> setOption ( CURLOPT_HTTPHEADER , $ this -> prepareHeaders ( $ requestHeaders ) ) ; } if ( ! empty ( $ postFields ) ) { $ handle -> setOption ( CURLOPT_POST , true ) ; $ handle -> setOption ( CURLOPT_POSTFIELDS , http_build_query ( $ postFields ) ) ; } $ response = $ handle -> execute ( ) ; $ statusCode = $ handle -> getInfo ( CURLINFO_HTTP_CODE ) ; $ handle -> close ( ) ; if ( $ response && $ returnResponseHeaders ) { return $ this -> splitResponseHeaderAndBody ( $ response , $ statusCode ) ; } return $ response ; }
Create a curl post request.

@param string $url
@param array  $requestHeaders
@param array  $postFields
@param bool   $returnResponseHeaders

@return array|mixed
Create a curl post request .