Send a POST request with JSON-encoded params.

@param string $path
@param array  $params
@param array  $headers

@throws \Http\Client\Exception

@return array
767403
protected function post(string $path, array $params = [], array $headers = [])
    {
        $body = self::createJsonBody($params);

        if ($body) {
            $headers = self::addJsonContentType($headers);
        }

        return $this->postRaw($path, $body, $headers);
    }
287125
public static function post($url, $params, $headers=null)
	{
		$self = new self();
		if ( is_array($params) ) {
			$params = http_build_query($params);
		}
		$curl = $self->_curlInit($url, $headers);
		curl_setopt($curl, CURLOPT_POST, true);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $params);

		return $self->_doRequest($curl, false);
	}
1062744
protected function httpPost(string $path, array $params = [], array $requestHeaders = []): ResponseInterface
    {
        $requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';

        return $this->httpPostRaw($path, http_build_query($params), $requestHeaders);
    }
678951
protected function post($path, array $parameters = [], array $requestHeaders = [])
    {
        return $this->postRaw(
            $path,
            $this->createJsonBody($parameters),
            $requestHeaders
        );
    }
414441
protected function createRedirect($path, $status, $headers)
    {
        $redirect = new RedirectResponse($path, $status, $headers);

        $redirect->setRequest($this->app->make('request'));

        return $redirect;
    }
950243
public function post($path, $params, $multipart = false)
    {
        return $this->ttools->makeRequest(
            TTools::API_BASE . '/' . TTools::API_VERSION . $path,
            $params,
            'POST',
            $multipart
        );
    }
1963
public function request(string $path, array $params = null, string $method = null, $body = null, array $headers = null):ResponseInterface{

		parse_str(parse_url($this->apiURL.$path, PHP_URL_QUERY), $query);

		$query['v'] = $this::API_VERSIONDATE;
		$query['m'] = 'foursquare';

		return parent::request(explode('?', $path)[0], array_merge($params ?? [], $query), $method, $body, $headers);
	}
90654
public function post($path, $vars = array()) {
    $request = $this->request();
    $request = $this->prepareRequest($request);

    $response = $request->post($this->endpoint . $path, $vars);
    return $this->handleResponse($response);
  }
815057
public function delete($path, array $parameters = [], array $requestHeaders = [])
    {
        $response = $this->getHttpClient()->delete($path, $requestHeaders, $this->createJsonBody($parameters));

        return ResponseMediator::getContent($response);
    }
1268417
public function api($url, $method, array $params = [], array $headers = [])
    {
        try {
            return $this->sendRequest($method, $url, $params, $headers);
        } catch (\Exception $e) {
            sleep(2);
            return $this->sendRequest($method, $url, $params, $headers);
        }
    }
1005057
protected function send(string $method, $path, array $headers = [], $body = []): Contracts\Response
    {
        if ($this instanceof Contracts\Filterable) {
            $body = $this->filterRequest($body);
        }

        $endpoint = ($path instanceof Contracts\Endpoint)
                        ? $this->getApiEndpoint($path->getPath())->addQuery($path->getQuery())
                        : $this->getApiEndpoint($path);

        $message = $this->responseWith(
            $this->client->send($method, $endpoint, $headers, $body)
        );

        return $this->interactsWithResponse($message);
    }
169702
public function put($path, $params)
    {
        $response = $this->http_client->request('PUT', $path, $params);
        $this->handleErrors($response);
        return $response;
    }
693365
protected function sendRequest($method, $url, array $params = [], array $headers = [])
    {
        $response = $request = $this->getHttpClient()->createRequest()
            ->setUrl($url)
            ->setMethod($method)
            ->setHeaders($headers)
            ->setData($params)
            ->send();
        if (!$response->isOk && $this->debug) {
            throw new Exception ('Http request failed.');
        }
        return $response;
    }
64190
protected function __curl($path, $method = 'GET', array $params = array(), array $headers = array()) {
        $this->ret = [];
        
        // only JSON for now
        $headers[] = 'Content-Type: application/json';
        $headers[] = 'Accept: application/json';

        $options = array();
        $options[CURLOPT_RETURNTRANSFER] = true;
        $options[CURLOPT_HEADER] = true;
        $options[CURLOPT_TIMEOUT] = $this->timeout;
        $options[CURLOPT_CUSTOMREQUEST] = $method;
        $options[CURLOPT_HTTPHEADER] = $headers;

        if ($method == 'POST') {
            // not doing this, since we are json-only for now
            //$options[CURLOPT_POST] = 1;

            $options[CURLOPT_POSTFIELDS] = json_encode($params);            

        } elseif ($method == 'GET') {
            $par = http_build_query($params);

            if (strlen($par)) {
                if (preg_match('/\?/', $path)) {
                    $path .= '&' . $par;
                } else {
                    $path .= '?' . $par;
                }
            }

        }

        $options[CURLOPT_URL] = $path;

        $this->req = [
            'path' => $path, 
            'method' => $method, 
            'headers' => $headers, 
            'options' => $options,
        ];
        
        $curl = curl_init();
        curl_setopt_array($curl, $options); 
        
        $resp = curl_exec($curl);
        $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        $this->ret['header'] = substr($resp, 0, $header_size);
        $this->ret['body'] = substr($resp, $header_size);        
        $this->ret['error'] = curl_error($curl);
        $this->ret['code'] = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        curl_close($curl);
        
        return $this->ret;        
        
    }
167860
public function get($path, $params = null){
        $url_params = '';
        if (is_array($params)){
            $url_params = '?' . http_build_query($params);
        }
        
        return $this->_call('GET', $path . $url_params);
    }
138356
public function makeRequest($path, $params)
    {
        $this->dispatcher->dispatch('api.createUri', 
            new GenericEvent($this, array(
                'path' => $path,
                'params' => $params
            ))
        );

        $this->response = $this->browser->get($this->getUri());       

        $parsedResponse = json_decode($this->response->getContent(), true);
        if (array_key_exists('errors', $parsedResponse)) {
            throw new NewscoopApiException($parsedResponse);
        }

        return $this;
    }
1135549
protected function doPost(string $path, array $parameters = [], array $headers = [])
    {
        $body = \json_encode($parameters);

        $request = $this
            ->getInstapushClient()
            ->getRequestFactory()
            ->createRequest('POST', $path, $headers, $body);

        $this->setRequest($request);

        $response = $this
            ->getInstapushClient()
            ->getHttpClient()
            ->sendRequest($request);

        $this->setResponse($response);

        return $this;
    }