Makes the curl request to the url.

@param string $url url to request.
@param array $options HTTP request options. Keys: query, data, referer.
@param boolean $parseJson Whether to parse response in json format.
@return stdClass the response.
551062
protected function makeRequest($url, $options = array(), $parseJson = true) {
		$ch = $this->initRequest($url, $options);

		$result = curl_exec($ch);
		$headers = curl_getinfo($ch);

		if (curl_errno($ch) > 0) {
			throw new EAuthException(curl_error($ch), curl_errno($ch));
		}

		if ($headers['http_code'] != 200) {
			Yii::log(
				'Invalid response http code: ' . $headers['http_code'] . '.' . PHP_EOL .
					'URL: ' . $url . PHP_EOL .
					'Options: ' . var_export($options, true) . PHP_EOL .
					'Result: ' . $result,
				CLogger::LEVEL_ERROR, 'application.extensions.eauth'
			);
			throw new EAuthException(Yii::t('eauth', 'Invalid response http code: {code}.', array('{code}' => $headers['http_code'])), $headers['http_code']);
		}

		curl_close($ch);

		if ($parseJson) {
			$result = $this->parseJson($result);
		}

		return $result;
	}
266659
public function makeSignedRequest($url, $options = [], $parseResponse = true)
	{
		$options['query']['format'] = 'json';
		return parent::makeSignedRequest($url, $options, $parseResponse);
	}
579971
public static function post($url, $data = [], $options = [])
    {
        $options['data'] = $data;
        return self::doRequest('post', $url, $options);
    }
1050036
public function post($url, $params = '', $curlOptions = array()) {
        if (is_array($params)) {
            $params = $this->makePostFields($params);
        }
        $curlOptions['CURLOPT_POST'] = 1;
        $curlOptions['CURLOPT_POSTFIELDS'] = $params;
        return $this->request($url, $curlOptions);
    }
307896
protected function fetch($url, array $params = [], array $curl_options = []){
		$requestOptions               = new RequestOptions;
		$requestOptions->curl_options = $curl_options;
		$requestOptions->ca_info      = $this->ca_info;

		return (new Request($requestOptions))->fetch(new URL($url, $params));
	}
8680
public function post($url, array $params = null, array $options = array())
	{
		return $this->request($url, 'POST', $params, $options);
	}
559763
protected function request($url, $method = self::GET, $params = array(), $options = array())
    {
        if (in_array($method, array(self::GET, self::DELETE)) && count($params)) {
            $url .= (stripos($url, '?') ? '&' : '?') . http_build_query($params);
            $params = array();
        }

        curl_setopt($this->curl, CURLOPT_HEADER, true);
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);

        curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($this->curl, CURLOPT_URL, $url);

        curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($this->curl, CURLOPT_TIMEOUT, 30);

        // File Upload
        if (isset($options['files']) && count($options['files']) > 0) {
            foreach ($options['files'] as $index => $file) {
                $params[$index] = $this->createCurlFile($file);
            }
            version_compare(PHP_VERSION, '5.5', '<') || curl_setopt($this->curl, CURLOPT_SAFE_UPLOAD, false);
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, $params);
        } elseif (isset($options['xml'])) {
            $options['headers'][] = 'content-type:text/xml';
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, $params['xml']);
        } elseif (isset($options['json'])) {
            $options['headers'][] = 'content-type:application/json';
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, Json::encode($params));
        } elseif (in_array($method, array(self::POST))) {
            curl_setopt($this->curl, CURLOPT_POSTFIELDS, http_build_query($params));
        } else {

        }

        // Check for custom headers
        if (isset($options['headers']) && count($options['headers']))
            curl_setopt($this->curl, CURLOPT_HTTPHEADER, $options['headers']);

        // Check for basic auth
        if (isset($options['auth']['type']) && 'basic' === $options['auth']['type'])
            curl_setopt($this->curl, CURLOPT_USERPWD, $options['auth']['username'] . ':' . $options['auth']['password']);

        $response = $this->doCurl();
        // Separate headers and body
        $headerSize = $response['curl_info']['header_size'];
        $header = substr($response['response'], 0, $headerSize);
        $body = substr($response['response'], $headerSize);
        $results = array(
            'curl_info' => $response['curl_info'],
            'content_type' => $response['curl_info']['content_type'],
            'status' => $response['curl_info']['http_code'],
            'headers' => $this->splitHeaders($header),
            'data' => $body,
        );
        if ($response['response'] === false)
            $results['curl_error'] = curl_error($this->curl);
        return $results;
    }
965389
public function get($url, array $params = null, array $options = array())
	{
		return $this->request($url, 'GET', $params, $options);
	}
158494
private function curlRequest($url)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_COOKIESESSION, true);
        $data = curl_exec($curl);
        $info = curl_getinfo($curl);
        curl_close($curl);

        if (200 !== $info['http_code']) {
            throw new HttpException($info['http_code']);
        }

        return json_decode($data, true);
    }
510318
public function makeRequest($url, $options = [], $parseResponse = true)
    {
        return $this->request($url, $options, $parseResponse, function ($url, $method, $headers, $data) {
            return $this->getHttpClient()->retrieveResponse($url, $data, $headers, $method);
        });
    }
169477
private function request($url, array $options)
    {
        $response = $this->client->request('POST', $url, $options);

        $body = $response->getBody();
        if ($response->getStatusCode() != 200
                || !isset($body)) {
            throw new \Exception('Failed request to ' . $this->endpoint . '.');
        }

        return $response;
    }
423324
protected function request($options = [])
    {
        try {
            $params = array_filter($this->params);
            $response = $this->getClient()
                ->get($this->getUrl(), ['query' => $params], $options);

            return trim($this->format) === 'json'
                ? json_decode($response->getBody(), true)
                : simplexml_load_string($response->getBody());
        } catch (RequestException $e) {
            return null;
        }
    }
835884
protected function curlGetOptions($url, $options = array())
    {
        $this->debug->groupCollapsed(__METHOD__);
        $urlParts = Html::parseUrl($url);
        $optionsDefault = $this->curlOptionsDefault($url);
        $options = $this->curlOptionsNormalize($options);
        // $this->debug->log('optionsDefault', $optionsDefault);
        $options = ArrayUtil::mergeDeep($optionsDefault, $options);
        $options['CURLOPT_URL'] = \str_replace(' ', '%20', $options['CURLOPT_URL']);
        $options['CURLOPT_FOLLOWLOCATION']  = false;    // we will follow manually
        if ($options['verbose']) {
            $options['CURLOPT_VERBOSE'] = true;
            /*
            $options['tempfile'] = tempnam(\sys_get_temp_dir(), 'curl_');
            if (\is_writable($options['tempfile'])) {
                $fh = \fopen($options['tempfile'], 'w+');
                $options['CURLOPT_STDERR'] = $fh;
            }
            */
            $options['CURLINFO_HEADER_OUT'] = false;    // https://bugs.php.net/bug.php?id=65348
            $options['CURLOPT_STDERR'] = \fopen('php://temp', 'rw');
        }
        if (!empty($options['CURLOPT_PROXY']) && \in_array($urlParts['host'], array('127.0.0.1','localhost'))) {
            $this->debug->log('not using proxy for localhost');
            $options['CURLOPT_PROXY'] = false;  // formerly set to null... which no longer works
        }
        if (empty($options['CURLOPT_PROXY']) && \getenv('http_proxy')) {
            $this->debug->log('http_proxy env variable is set.... setting NO_PROXY env variable');
            \putenv('NO_PROXY='.$urlParts['host']);
        }
        $this->debug->groupEnd();
        return $options;
    }
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);
    }
1275167
private function executeQuery(string $url): \stdClass
    {
        $content = $this->getUrlContents($url);
        $json = json_decode($content);
        // API error
        if (!isset($json)) {
            throw InvalidServerResponse::create($url);
        }

        return $json;
    }
584252
public static function curlGet($url = '', $options = array())
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        if (!empty($options)) {
            curl_setopt_array($ch, $options);
        }
        //https请求 不验证证书和host
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }
30434
public function request($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
        curl_setopt($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

        $result = curl_exec($ch);
        curl_close($ch);

        return json_decode($result);
    }