Send a POST request to youhosting.com

@param string $url the relative url
@param array $data an array of post data
@return Response
@throws YouHostingException
162479
public function post($url, $data)
    {
        $request = $this->webclient->createRequest('POST', $url, array(
            'body' => $data,
        ));
        return $this->sendRequest($request);
    }
1031889
public function buildGetRequestObject(string $url, array $data = null): Request
    {
        $requestOptions = [
            RequestOptions::QUERY => $data
        ];
        $options = $this->buildRequest(self::METHOD_GET, $url, $requestOptions);
        $headers = isset($options[self::OPTION_OPTIONS][RequestOptions::HEADERS]) ? $options[self::OPTION_OPTIONS][RequestOptions::HEADERS] : [];
        $body = isset($options[self::OPTION_OPTIONS][RequestOptions::BODY]) ? $options[self::OPTION_OPTIONS][RequestOptions::BODY] : null;
        $version = isset($options[self::OPTION_OPTIONS][RequestOptions::VERSION]) ? $options[self::OPTION_OPTIONS][RequestOptions::VERSION] : '1.1';
        return new Request($options[self::OPTION_METHOD], $options[self::OPTION_URL], $headers, $body, $version);
    }
552080
public function request($method, $url, $data = array())
    {
        $url = Api::getFullUrl($url);

        $hooks = new Requests_Hooks();

        $hooks->register('curl.before_send', array($this, 'setCurlSslOpts'));

        $options = array(
            'auth' => array(Api::getKey(), Api::getSecret()),
            'hook' => $hooks,
            'timeout' => 60,
        );

        $headers = $this->getRequestHeaders();

        $response = Requests::request($url, $headers, $data, $method, $options);

        $this->checkErrors($response);

        return json_decode($response->body, true);
    }
948064
public function put($url, $data = [])
    {
        $this->setOpt(CURLOPT_URL, $url);
        $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PUT');
        $this->setOpt(CURLOPT_POSTFIELDS, http_build_query($data));

        return $this->exec();
    }
685044
public function put($url, $data = '$undefined')
    {
        if ($data === '$undefined') {
            $data = ($url instanceof Resource)
                ? $url->data()
                : null;
        }
        return $this->request('put', $url, $data);
    }
907991
public function get($url, array $data = [])
    {
        if (count($data) > 0) {
            $this->setopt(CURLOPT_URL, $url.'?'.http_build_query($data));
        } else {
            $this->setopt(CURLOPT_URL, $url);
        }
        $this->setopt(CURLOPT_HTTPGET, true);
        $this->_exec();
    }
31554
public function postRequest($uri, array $data = null)
    {
        return $this->getClient()->post($uri, [
            'json' => $this->createBody($data)
        ]);
    }
25490
public function post($url, array $data = [])
    {
        $this->resetAndAssociateUrl($url);

        if (!curl_setopt($this->ch, CURLOPT_POST, true)) {
            if (!empty($this->attach)) {
                curl_setopt($this->ch, CURLOPT_SAFE_UPLOAD, true);

                foreach ($this->attach as $key => $attach) {
                    $this->attach[$key] = '@'.ltrim('@', $attach);
                }

                $data = array_merge($this->attach, $data);
            }

            $this->addFields($data);
        }

        return new Parser($this->ch);
    }
111947
protected function _post($url, $data = [], $class = null) {
        $client = new HttpClient($this->patrol, 'post', $url, $data);

        $data = $client->response();

        if (isset($data['error'])) {
            $this->_error($data);
        }

        if (!isset($data['data'])) {
            return $data;
        }

        $data = $data['data'];

        $callee = $class ? $class : get_called_class();
        return Util::parseResponseToPatrolObject($this->patrol, $data, $callee, $this->defaults);
    }
582917
public function send($url, $method = 'GET', $data = [])
    {
        $method = strtolower($method);

        $settings = [
            'headers'  => array_merge([
                'Authorization' => 'Bearer ' . $this->getToken(),
                'Content-Type' => 'application/x-www-form-urlencoded',
            ], $this->getHeaders()),
        ];

        if ($method == 'post') {
            $settings['form_params'] = $data;
        }

        return $this->client
            ->$method($url, $settings);
    }
1039319
public static function post($url, $data = null, $accepts_cookie = true, $compression = 'gzip', $proxy = '')
    {
        $self = new static($accepts_cookie, $compression, $proxy);
        return $self->sendPOST($url, $data);
    }
349178
public function redirect(string $url, array $data = []) : void
    {
        $this->redirectUrl = $url;
        $this->redirectData = $data;
    }
274314
public function post($url, array $params = [])
    {
        return $this->request($this->createUrl($url), self::METHOD_POST, $params);
    }
1108678
protected function buildUrl($url, array $data)
    {
        if (!$data) {
            return $url;
        }

        if (strpos($url, '?') === false) {
            $url .= '?';
        } elseif (substr($url, 0, -1) != '?') {
            $url .= '&';
        }

        return $url . http_build_query($data);
    }
122146
protected function apiPost($url, $data)
    {
        if (empty($data['client_ip'])) {
            $data['client_ip'] = sprintf("%d.%d.%d.%d", rand(1, 244), rand(1, 244), rand(1, 244), rand(1, 244));
        }

        $response = $this->apiClient->post($url, array(
            'body' => $data,
        ));

        return $this->processResponse($response);
    }
198868
public function post($url, array $query = [], array $data = [], array $files = [])
    {
        $url = $this->buildUrl($url, $query);

        if ($files) {
            foreach ($files as $key => $file) {
                $data[$key] = new CURLFile($file['tmp_name']);
            }
        } else {
            $data = http_build_query($data);
        }

        $handle = $this->getHandler();

        curl_setopt_array($handle, [
            CURLOPT_CUSTOMREQUEST => 'POST',
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => $data,
        ]);

        return $this->run($handle, $url);
    }
1243683
public function post($url, $data = [], $params = null)
    {
        foreach ($data as $val) {
            if ($val instanceof UploadFile) {
                $params['contentType'] = 'multipart/form-data';
            }
        }
        if (!isset($params['contentType'])) {
            $params['contentType'] = 'application/x-www-form-urlencoded';
        }
        if ($params['contentType'] === 'application/x-www-form-urlencoded') {
            $body = http_build_query($data, '', '&', PHP_QUERY_RFC3986);
        } elseif ($params['contentType'] === 'application/x-json' || $params['contentType'] === 'application/json') {
            $body = json_encode($data);
        } else {
            $body = 'Unsupported Content-Type';
        }
        if (!isset($params['headers'])) {
            $params['headers'] = [];
        }
        $params['headers']['Content-Length'] = mb_orig_strlen($body);
        $this->sendRequestHeaders('POST', $url, $params);
        $this->write($body);
        $this->writeln('');
    }