Post

@param string $url
@param array $options
@return array
177178
public static function post(string $url, array $options = []) : array {
		$result = [
			'success' => false,
			'error' => [],
			'data' => null
		];
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query2($options['params']));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$result['data'] = curl_exec($ch);
		if (!empty($options['json'])) {
			$result['data'] = json_decode($result['data'], true);
		}
		curl_close($ch);
		$result['success'] = true;
		return $result;
	}
937092
public function post($params = array(), $options = array())
	{
		// If its an array (instead of a query string) then format it correctly
		if (is_array($params))
		{
            if($this->format == "json"){
                $params = json_encode($params);
            }else{
                if(!empty($_FILES)){
                    foreach($_FILES as $fileField => $fileVal){
                        $params[$fileField] = curl_file_create($fileVal['tmp_name'], $fileVal['type'], $fileVal['name']);
                    }
                }else{
					$params = http_build_query($params, NULL, '&');
				}
            }
		}

		// Add in the specific options provided
		$this->options($options);

		$this->http_method('post');

		$this->option(CURLOPT_POST, TRUE);
		$this->option(CURLOPT_POSTFIELDS, $params);
	}
1004978
public function delete($url, $params = array(), $options = array())
    {
        return $this->request($url, self::DELETE, $params, $options);
    }
450305
public function get($url, $params = array(), $options = array()) {
        $options['CURLOPT_HTTPGET'] = 1;

        if (!empty($params)) {
            $url .= (stripos($url, '?') !== false) ? '&' : '?';
            $url .= http_build_query($params, '', '&');
        }
        return $this->request($url, $options);
    }
159240
public static function get($url, $query = [], $options = [])
    {
        $options['query'] = $query;
        return self::doRequest('get', $url, $options);
    }
527940
protected function _request($method, $url, $params = [], $options = null)
    {
        $opts = $this->_opts->merge($options);
        list($resp, $options) = static::_staticRequest($method, $url, $params, $opts);
        $this->setLastResponse($resp);
        return [$resp->json, $options];
    }
174812
public static function match($url, $options)
    {
        if (!is_array($options)) {
            $tmpString = $options;
            $options = null;
            $options['host'] = $tmpString;
        }

        // build the rules
        $rules = '';
        foreach ($options as $key => $value) {
            switch (Str::lower($key)) {
                case 'scheme':
                    $rules .= "|scheme:${value}";
                    break;
                case 'user':
                    $rules .= "|user:${value}";
                    break;
                case 'pass':
                    $rules .= "|pass:${value}";
                    break;
                case 'host':
                    $rules .= "|host:${value}";
                    break;
                case 'subdomain':
                    $rules .= "|subdomain:${value}";
                    break;
                case 'domain':
                    $rules .= "|domain:${value}";
                    break;
                case 'tld':
                    $rules .= "|tld:${value}";
                    break;
                case 'port':
                    $rules .= "|port:${value}";
                    break;
                case 'path':
                    $rules .= "|path:${value}";
                    break;
                case 'query':
                    $rules .= "|query:${value}";
                    break;
                case 'fragment':
                    $rules .= "|fragment:${value}";
                    break;
            }
        }

        $validate = Validator::make(['url' => $url], [
            'url' => 'required|url'.$rules,
        ]);

        return $validate->passes();
    }
1300280
public function send(string $url, array $options = []): array
    {
        $response = $this->client->get($url, $options);

        $result = \GuzzleHttp\json_decode($response->getBody()->getContents(), true);
        if (!empty($result['Command']) && $result['Command'] === 'Unknown') {
            throw new UnknownCommandException('command is unknown');
        }

        return $result;
    }
360934
private function sendRequest($method, $url, array $options = [])
    {
        $response = $this->httpClient->request((string)$method, $url, $options);

        return json_decode($response->getBody(), true);
    }
228267
public static function post(string $url, array $params = null, array $headers = null)
    {
        return static::quickRequest($url, self::POST, $params, $headers);
    }
846582
protected function initRequest($url, $options = array()) {
		$ch = curl_init();
		//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // error with open_basedir or safe mode
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

		if (isset($options['referer'])) {
			curl_setopt($ch, CURLOPT_REFERER, $options['referer']);
		}

		if (isset($options['headers'])) {
			curl_setopt($ch, CURLOPT_HTTPHEADER, $options['headers']);
		}

		if (isset($options['query'])) {
			$url_parts = parse_url($url);
			if (isset($url_parts['query'])) {
				$query = $url_parts['query'];
				if (strlen($query) > 0) {
					$query .= '&';
				}
				$query .= http_build_query($options['query']);
				$url = str_replace($url_parts['query'], $query, $url);
			}
			else {
				$url_parts['query'] = $options['query'];
				$new_query = http_build_query($url_parts['query']);
				$url .= '?' . $new_query;
			}
		}

		if (isset($options['data'])) {
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $options['data']);
		}

		curl_setopt($ch, CURLOPT_URL, $url);
		return $ch;
	}
287374
protected function sendRequest($url, $method = 'get', array $options = [])
    {
        return $this->send(
          new Request($method, $url),
          $this->client,
          $options
        );
    }
418283
protected function loadRemoteOptions($url, $parameters = [], $options = [])
    {
        $ajaxOptions = [
            'url' => $url.'?'.http_build_query($parameters),
        ];
        $configs = array_merge([
            'allowClear'         => true,
            'placeholder'        => [
                'id'        => '',
                'text'      => trans('admin.choose'),
            ],
        ], $this->config);

        $configs = json_encode($configs);
        $configs = substr($configs, 1, strlen($configs) - 2);

        $ajaxOptions = json_encode(array_merge($ajaxOptions, $options));

        $this->script = <<<EOT

$.ajax($ajaxOptions).done(function(data) {

  var select = $("{$this->getElementClassSelector()}");

  select.select2({
    data: data,
    $configs
  });
  
  var value = select.data('value') + '';
  
  if (value) {
    value = value.split(',');
    select.select2('val', value);
  }
});

EOT;

        return $this;
    }
547942
public function post($url, $parameters = [])
    {
        $url = static::LOCATION.$url;
        $headers = $this->buildHeaders();

        $request = $this->requestProvider->createRequest('POST', $url, $headers, json_encode($parameters));
        $response = $this->client->send($request);

        $this->errorCheckResponse($response);

        return json_decode($this->streamToString($response->getBody()));
    }
846341
public function fetch($url, $options)
    {
        $this->init();

        $request_type = $this->config->http_post === true ?
            'form_params' : 'query';
        $options = [$request_type => $options];

        try {
            $response = $this->client->request(
                $this->config->http_post === true ? 'POST' : 'GET',
                $url,
                $options
            );
        } catch (GuzzleException $exception) {
            throw new ConnectionException(
                $exception->getMessage(),
                $exception->getCode()
            );
        }

        if ($response->getStatusCode() >= 400) {
            // ccp is using error codes even if they send a valid application
            // error response now, so we have to use the content as result
            // for some of the errors. This will actually break if CCP ever uses
            // the HTTP Status for an actual transport related error.
            switch ($response->getStatusCode()) {
                case 400:
                case 403:
                case 500:
                case 503:
                    return $response->getBody()->getContents();
                    break;
            }

            throw new HTTPException(
                $response->getStatusCode(),
                $url
            );
        }

        return $response->getBody()->getContents();
    }
1325151
protected function executeCurl($url, array $options = array())
    {
        $session = curl_init($url);

        if (count($options)) {
            curl_setopt_array($session, $options);
        }

        $response = curl_exec($session);

        $error = false;
        $info = curl_getinfo($session);
        if ($response === false) {
            $error = curl_error($session);
        }

        curl_close($session);

        return array($response, $info, $error);
    }
519164
public function json($url, $params = [], array $options, $encodeOption = JSON_UNESCAPED_UNICODE)
    {
        is_array($params) && $params = json_encode($params, $encodeOption);

        return $this->request($url, 'POST', ['body' => $options, 'headers' => ['content-type' => 'application/json']], $options);
    }